- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.2k
 
Enable same linters as the Prometheus repo itself #1056
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d8e8581
              
                Add gofumpt to github workflow & fix all files for it
              
              
                sazary d1bc032
              
                Add goimports to golangci & fix it's issues
              
              
                sazary 9e10beb
              
                Add revive to golangci & fix it's issues
              
              
                sazary 3dfd8d0
              
                Add errcheck & misspell to golangci and fix their issues
              
              
                sazary af8a55f
              
                Add govet & gosimple to golangci and fix their issues
              
              
                sazary 2805eab
              
                Enable all default linters of golangci
              
              
                sazary File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| --- | ||
| name: golangci-lint | ||
| on: | ||
| push: | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,31 @@ | ||
| # Run only staticcheck for now. Additional linters will be enabled one-by-one. | ||
| --- | ||
| 
     | 
||
| run: | ||
| deadline: 5m | ||
| 
     | 
||
| output: | ||
| sort-results: true | ||
| 
     | 
||
| linters: | ||
| enable: | ||
| - staticcheck | ||
| disable-all: true | ||
| - gofumpt | ||
| - goimports | ||
| - revive | ||
| - misspell | ||
| 
     | 
||
| issues: | ||
| max-same-issues: 0 | ||
| exclude-rules: | ||
| - path: _test.go | ||
| linters: | ||
| - errcheck | ||
| - govet | ||
| - structcheck | ||
| 
     | 
||
| linters-settings: | ||
| errcheck: | ||
| exclude: scripts/errcheck_excludes.txt | ||
| goimports: | ||
| local-prefixes: github.com/prometheus/client_golang | ||
| gofumpt: | ||
| extra-rules: true | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -72,7 +72,8 @@ const ( | |
| // | ||
| // The current default is GoRuntimeMemStatsCollection, so the compatibility mode with | ||
| // client_golang pre v1.12 (move to runtime/metrics). | ||
| func WithGoCollections(flags GoCollectionOption) goOption { | ||
| //nolint:staticcheck // Ignore SA1019 until v2. | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is staticcheck enabled? From the config above, it doesn't seem like it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as #1056 (comment)  | 
||
| func WithGoCollections(flags GoCollectionOption) func(options *prometheus.GoCollectorOptions) { | ||
| return func(o *goOptions) { | ||
| o.EnabledCollections = uint32(flags) | ||
| } | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These linters don't seem to be enabled, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golangci-linthas a list of default linters that are enabled by default, unless being disabled explicitly or implicitly. in the previous config they were disabled implicitly by usingdisable-all: truein this linethe default linters list is:
since in the main prometheus repo they left them enabled implicitly i did the same too but i understand that it could reduce readability.
do you want me to enable them in the config explicitly or leave them as they are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having them explicit would be amazing. Also, this would prevent any unwanted issues, if we upgrade golangci-lint and decide to change their default preset.