go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

Code coverage: cover.cov location is not based on the current file's path

Open maruel opened this issue 1 year ago • 0 comments

Related to issue #526.

lua/go/coverage.lua hardcodes "cover.cov" in the current working directory and not in the directory containing of the active buffer's file path.

Ref:

  • https://github.com/ray-x/go.nvim/blob/6368756601a358b1491ac2ff10d0e2939a76df5e/lua/go/coverage.lua#L185
  • https://github.com/ray-x/go.nvim/blob/6368756601a358b1491ac2ff10d0e2939a76df5e/lua/go/coverage.lua#L308

This is problematic for two reasons:

  • When opening a file in a subdirectory, the file is not in the right location. E.g. nvim foo/bar.go will create cover.cov in the current directory, not under foo/.
    • Similar wrong behavior if running nvim ../foo/bar.go
  • This file has to be ignored in git.

Solution

One of:

  • Default to a temporary file that is automatically cleaned up upon editor exit
  • Use a well known location in ~/.cache/
  • Use the file's current directory

maruel avatar Nov 21 '24 21:11 maruel