Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no go files to analyze #78

Closed
NSObjects opened this issue Jul 28, 2021 · 12 comments
Closed

no go files to analyze #78

NSObjects opened this issue Jul 28, 2021 · 12 comments

Comments

@NSObjects
Copy link

GoLand 2021.1.3
Build #GO-211.7442.57, built on June 9, 2021

golangci-lint has version v1.41.1

Go Linter 1.5.3

image

image

@xxpxxxxp
Copy link
Owner

Hi @NSObjects , I'm afraid I didn't understand your question, those 2 screenshots don't seem related to the plugin? The plugin does not output anything, it does lint in editor.

And BTW the problem of the first screenshot is that the current running dir should be at
/Users/mac/Documents/Code/Go/mxtio/jsm_live

@sleyland
Copy link

sleyland commented Aug 2, 2021

I am also receiving this error, even after the latest plugin updates (running v1.5.4). This is the error output in the GoLand log file (NOTE: I've removed my username from the path and replaced with <user>):

2021-08-02 10:12:56,401 [1723930]  DEBUG - BackendServerFileEditorManager - Opening host editor for /Users/<user>/workspace/gocode/src/bitbucket.org/ffxblue/api-content/lib/api/asset.go 
2021-08-02 10:12:56,896 [1724425]   INFO - leTypes.UpdateComponentWatcher - updated: https://plugins.jetbrains.com/plugins/list?pluginId=org.jetbrains.plugins.go&build=GO-212.4746.93&pluginVersion=212.4746.93&os=Mac+OS+X+11.5.1&uuid=2807212b1b9dbca-8ede-4042-857e-6f9c17dcee14 
2021-08-02 10:12:57,921 [1725450]   WARN -                      go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze"
. Please make sure the project has no syntax error. 
2021-08-02 10:12:57,929 [1725458]   WARN -                      go-linter - Debug command: cd /Users/<user>/workspace/gocode/src/bitbucket.org/ffxblue/api-content && export PATH=/usr/local/Cellar/go/1.16.6/libexec/bin:/usr/bin:/bin:/usr/sbin:/sbin && export GOPATH= && '/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '3' '--max-issues-per-linter' '0' '--max-same-issues' '0' '-c' '/Users/<user>/workspace/docker-go-linter/config/golangci-lint/full/.golangci.yaml' 'lib/api' 
2021-08-02 10:13:03,339 [1730868]   INFO - System.impl.PopupMenuPreloader - Popup menu preloaded for `EditorPopup` in 15 ms

I am referencing a golangci-lint.yaml configuration file, however, removing that file as a configuration and replacing with the same selected linters also results in the same error.

I have tried the following:

  • uninstall plugin
  • reset IDE to 'default settings'
  • reinstall plugin
  • multiple configuration options

Setup:
MacOSX BigSur v11.5.1
Goland v2021.2
Golangci-lint plugin v1.5.4
Golangci-lint installed through Homebrew v1.41.1

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Aug 2, 2021

Hi @sleyland , from the Debug command in the log, it seems there's no GOPATH set in IDE

cd /Users/<user>/workspace/gocode/src/bitbucket.org/ffxblue/api-content
export PATH=/usr/local/Cellar/go/1.16.6/libexec/bin:/usr/bin:/bin:/usr/sbin:/sbin
export GOPATH=
'/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '3' '--max-issues-per-linter' '0' '--max-same-issues' '0' '-c' '/Users/<user>/workspace/docker-go-linter/config/golangci-lint/full/.golangci.yaml' 'lib/api'

Please check your settings
image

@sleyland
Copy link

sleyland commented Aug 2, 2021

Hi @xxpxxxxp

I've rechecked the IDE settings and there is a globally configured GOPATH. See attached screenshot

Screen Shot 2021-08-03 at 7 22 52 am

I've also checked in my terminal by simply doing an echo $GOPATH and that outputs the same information that is defined in Goland.

NOTE: I've also tried this in IntelliJ to see if there was any difference (not that there should be) and it also fails for the same reasons there (since that was the editor you demonstrated in your screenshot).

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Aug 3, 2021

Thanks @sleyland for quick reply, would you try following commands in your terminal, with GOPATH already set to see if the command works

cd /Users/<user>/workspace/gocode/src/bitbucket.org/ffxblue/api-content
export PATH=/usr/local/Cellar/go/1.16.6/libexec/bin:/usr/bin:/bin:/usr/sbin:/sbin
'/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '3' '--max-issues-per-linter' '0' '--max-same-issues' '0' '-c' '/Users/<user>/workspace/docker-go-linter/config/golangci-lint/full/.golangci.yaml' 'lib/api'

@sleyland
Copy link

sleyland commented Aug 3, 2021

Hi @xxpxxxxp,

Testing the command as you provided does work and provides prints a JSON style output to the terminal of all of the "issues" within the code. I did also get a warning with the output, but that seems more related to the linting configuration that is used in our projects.

WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref.

Thus, since the command works in the terminal with the $GOPATH already defined, then I'm assuming that the issue is something inside the Goland/IntelliJ environment where despite the interface indicating that it has found the $GOPATH it doesn't seem to be provided to the plugin correctly?

Thanks,

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Aug 4, 2021

Hi @sleyland , seems the problem is the plugin failed to get GOPATH defined in IDE, a quick workaround would be add a Project GOPATH, let me review codes find out root cause.

@sleyland
Copy link

sleyland commented Aug 8, 2021

Hi @xxpxxxxp ,

Apologies for not getting back to you sooner, but I've just added the appropriate Project GOPATH and it still causes the plugin to fail. Strangely however, copying and pasting the output debug command returns a working result?

Goland log output:

2021-08-09 08:04:11,511 [  13523]   WARN -                      go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze"
. Please make sure the project has no syntax error. 
2021-08-09 08:04:11,516 [  13528]   WARN -                      go-linter - Debug command: cd /Users/sleyland/workspace/gocode/src/bitbucket.org/ffxblue/api-content && export PATH=/usr/local/Cellar/go/1.16.6/libexec/bin:/usr/bin:/bin:/usr/sbin:/sbin && export GOPATH=/Users/sleyland/workspace/gocode && '/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '3' '--max-issues-per-linter' '0' '--max-same-issues' '0' '-c' '/Users/sleyland/workspace/docker-go-linter/config/golangci-lint/full/.golangci.yaml' 'lib/rpc/api/content/asset/v2' 

"Fresh" terminal output:

cd /Users/sleyland/workspace/gocode/src/bitbucket.org/ffxblue/api-content && export PATH=/usr/local/Cellar/go/1.16.6/libexec/bin:/usr/bin:/bin:/usr/s
bin:/sbin && export GOPATH=/Users/sleyland/workspace/gocode && '/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '3' '--max-issues-per-linter' '0' '--max-same-issues' '0' '-c' '/Users/sleyland/workspace/docker-go-linter/config/golangci-lint/full/.golangci.yaml' 'lib/rpc/api/content/asset/v2'
direnv: loading ~/workspace/gocode/src/bitbucket.org/ffxblue/api-content/.envrc
.env.override
direnv: export +HOST
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref.
{"Issues":[{"FromLinter":"wrapcheck","Text":"error returned from external package is unwrapped: sig: func bitbucket.org/ffxblue/api-content/vendor/google.golang.org/grpc/status.Error(c bitbucket.org/ffxblue/api-content/vendor/google.golang.org/grpc/codes.Code, msg string) error","Severity":"","SourceLines":["\treturn nil, status.Error(codes.Unimplemented, \"unimplemented\")"],"Replacement":null,"Pos":{"Filename":"lib/rpc/api/content/asset/v2/asset.go","Offset":655,"Line":22,"Column":14},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Warnings":[{"Tag":"runner","Text":"The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref."}],"Linters":[{"Name":"govet","Enabled":true,"EnabledByDefault":true},{"Name":"bodyclose","Enabled":true},{"Name":"noctx","Enabled":true},{"Name":"errcheck","Enabled":true,"EnabledByDefault":true},{"Name":"golint"},{"Name":"rowserrcheck","Enabled":true},{"Name":"staticcheck","Enabled":true,"EnabledByDefault":true},{"Name":"unused","Enabled":true,"EnabledByDefault":true},{"Name":"gosimple","Enabled":true,"EnabledByDefault":true},{"Name":"stylecheck","Enabled":true},{"Name":"gosec","Enabled":true},{"Name":"structcheck","Enabled":true,"EnabledByDefault":true},{"Name":"varcheck","Enabled":true,"EnabledByDefault":true},{"Name":"interfacer"},{"Name":"unconvert","Enabled":true},{"Name":"ineffassign","Enabled":true,"EnabledByDefault":true},{"Name":"dupl"},{"Name":"goconst","Enabled":true},{"Name":"deadcode","Enabled":true,"EnabledByDefault":true},{"Name":"gocyclo","Enabled":true},{"Name":"cyclop"},{"Name":"gocognit","Enabled":true},{"Name":"typecheck","Enabled":true,"EnabledByDefault":true},{"Name":"asciicheck"},{"Name":"gofmt"},{"Name":"gofumpt","Enabled":true},{"Name":"goimports","Enabled":true},{"Name":"goheader"},{"Name":"gci"},{"Name":"maligned"},{"Name":"depguard","Enabled":true},{"Name":"misspell","Enabled":true},{"Name":"lll"},{"Name":"unparam","Enabled":true},{"Name":"dogsled","Enabled":true},{"Name":"nakedret","Enabled":true},{"Name":"prealloc","Enabled":true},{"Name":"scopelint","Enabled":true},{"Name":"gocritic","Enabled":true},{"Name":"gochecknoinits","Enabled":true},{"Name":"gochecknoglobals","Enabled":true},{"Name":"godox"},{"Name":"funlen"},{"Name":"whitespace"},{"Name":"wsl","Enabled":true},{"Name":"goprintffuncname"},{"Name":"gomnd","Enabled":true},{"Name":"goerr113"},{"Name":"gomodguard"},{"Name":"godot"},{"Name":"testpackage","Enabled":true},{"Name":"nestif","Enabled":true},{"Name":"exportloopref","Enabled":true},{"Name":"exhaustive"},{"Name":"sqlclosecheck","Enabled":true},{"Name":"nlreturn"},{"Name":"wrapcheck","Enabled":true},{"Name":"thelper","Enabled":true},{"Name":"tparallel","Enabled":true},{"Name":"exhaustivestruct"},{"Name":"errorlint","Enabled":true},{"Name":"paralleltest"},{"Name":"makezero","Enabled":true},{"Name":"forbidigo","Enabled":true},{"Name":"ifshort","Enabled":true},{"Name":"predeclared","Enabled":true},{"Name":"revive","Enabled":true},{"Name":"durationcheck","Enabled":true},{"Name":"wastedassign","Enabled":true},{"Name":"importas"},{"Name":"nilerr","Enabled":true},{"Name":"forcetypeassert","Enabled":true},{"Name":"gomoddirectives"},{"Name":"promlinter"},{"Name":"tagliatelle"},{"Name":"nolintlint","Enabled":true}]}}%

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Aug 9, 2021

Hi @sleyland , that was surprising, the plugin is running the exact command inside. I guess there are some env variable differences between the IDE and the terminal. Please run the exact commands in the IDE terminal (View - Tool Windows - Terminal) see if it works for the IDE env.

@sleyland
Copy link

sleyland commented Aug 9, 2021

Hi @xxpxxxxp ,

The command also works inside the terminal within Goland/IntelliJ. The process I went through was:

  • opened a .go file in the editor
  • checked the event log to see that there was a configuration error with the plugin (there was)
  • opened the idea.log to grab the command that was executed
  • copy/paste the command from the idea.log into a terminal within Goland/IntelliJ
  • command output an appropriate response

So as you mentioned, it is likely that there is some environment variable difference between how it executes inside the IDE and then in the terminal.

Thanks,

@xxpxxxxp
Copy link
Owner

Hi @sleyland , I'm trying to reproduce the issue you are facing, since you are working on a non-open-source project, any chance you can try the plugin with an open-source project, eg: https://github.com/gin-gonic/gin codebase is smaller enough to clone and build in minutes, see if the plugin works.

@sleyland
Copy link

Hi @xxpxxxxp ,

Seemingly everything is working fine with that project in Goland/IntelliJ. I can see various highlighted warnings inside the code editor when using "my" linting configuration. I also checked the ide.log and couldn't see any issues being reported by the tool.

Thanks for looking into this, and apologies that the code I'm working on isn't open-source (making life difficult)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants