Skip to content

OCPBUGS-43157: update goimports targets #370

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 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
linters:
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
enable:
# default linters
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# optional linters
- goimports

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ manifests:
# Run go fmt against code
.PHONY: fmt
fmt:
hack/goimports.sh
go fmt ./...

# Run go vet against code
.PHONY: vet
Expand All @@ -69,7 +69,7 @@ vet:
# Run golangci-lint against code
.PHONY: lint
lint:
( GOLANGCI_LINT_CACHE=$(PROJECT_DIR)/.cache $(GOLANGCI_LINT) run --timeout 10m )
( GOLANGCI_LINT_CACHE=$(PROJECT_DIR)/.cache $(GOLANGCI_LINT) run --timeout 10m -v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we had this before, and there was no config file, does that mean it was just running with the default linters?

I'm concerned that adding a config with just the one linter is now disabling the default linters, can you please check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did check, and yes we were running the 6 defaults and with this config it goes up to 7. terminal output attached

$ make lint                                                                                                                                             
( GOLANGCI_LINT_CACHE=/home/mike/dev/cluster-cloud-controller-manager-operator/.cache go run /home/mike/dev/cluster-cloud-controller-manager-operator/ve
ndor/github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout 10m -v)                                                                          
INFO [config_reader] Config search paths: [./ /home/mike/dev/cluster-cloud-controller-manager-operator /home/mike/dev /home/mike /home /]               
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]                                                             
INFO [loader] Go packages loading at mode 575 (files|types_sizes|compiled_files|exports_file|name|deps|imports) took 254.169292ms                       
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.518242ms                                                                                 
INFO [linters_context/goanalysis] analyzers took 0s with no stages                                                                                      
INFO [runner] Issues before processing: 6, after processing: 0              
INFO [runner] Processors filtering stat (out/in): cgo: 6/6, path_prettifier: 6/6, skip_dirs: 6/6, exclude-rules: 1/6, filename_unadjuster: 6/6, autogene
rated_exclude: 6/6, skip_files: 6/6, identifier_marker: 6/6, exclude: 6/6, nolint: 0/1 
INFO [runner] processing took 778.124µs with stages: nolint: 632.408µs, identifier_marker: 42.244µs, autogenerated_exclude: 29.122µs, path_prettifier: 2
8.022µs, exclude-rules: 22.503µs, skip_dirs: 20.094µs, cgo: 1.103µs, max_same_issues: 446ns, fixer: 324ns, diff: 293ns, filename_unadjuster: 290ns, seve
rity-rules: 264ns, exclude: 221ns, uniq_by_line: 178ns, skip_files: 170ns, max_from_linter: 96ns, source_code: 80ns, sort_results: 75ns, path_shortener:
 70ns, max_per_file_from_linter: 64ns, path_prefixer: 57ns                  
INFO [runner] linters took 108.736888ms with stages: goanalysis_metalinter: 107.921807ms                                                                
INFO File cache stats: 0 entries of total size 0B                                                                                                       
INFO Memory: 5 samples, avg is 39.4MB, max is 67.2MB                                                                                                    
INFO Execution took 368.213838ms                                            
[mike@shift] update-fmt-and-imports ~/dev/cluster-cloud-controller-manager-operator                                                                     
$ vim .golangci.yaml                                                                                                                                    
[mike@shift] update-fmt-and-imports ~/dev/cluster-cloud-controller-manager-operator                                                                     
$ make lint                                                                 
( GOLANGCI_LINT_CACHE=/home/mike/dev/cluster-cloud-controller-manager-operator/.cache go run /home/mike/dev/cluster-cloud-controller-manager-operator/ve
ndor/github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout 10m -v)   
INFO [config_reader] Config search paths: [./ /home/mike/dev/cluster-cloud-controller-manager-operator /home/mike/dev /home/mike /home /]               
INFO [config_reader] Used config file .golangci.yaml                        
INFO [lintersdb] Active 7 linters: [errcheck goimports gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (exports_file|imports|types_sizes|compiled_files|deps|files|name) took 279.585394ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.498925ms                                                                                 
INFO [linters_context/goanalysis] analyzers took 1m54.742755847s with top 10 stages: buildir: 1m40.24997572s, nilness: 3.396365699s, fact_deprecated: 2.
163002325s, inspect: 2.147753962s, printf: 1.451514392s, fact_purity: 1.357569133s, ctrlflow: 1.328747476s, SA5012: 1.031048598s, typedness: 1.022998892
s, goimports: 78.306231ms                                                   
INFO [runner] Issues before processing: 6, after processing: 0                                                                                          
INFO [runner] Processors filtering stat (out/in): cgo: 6/6, path_prettifier: 6/6, identifier_marker: 6/6, filename_unadjuster: 6/6, skip_dirs: 6/6, auto
generated_exclude: 6/6, exclude: 6/6, exclude-rules: 1/6, nolint: 0/1, skip_files: 6/6 
INFO [runner] processing took 1.013784ms with stages: nolint: 786.051µs, identifier_marker: 64.982µs, autogenerated_exclude: 48.673µs, exclude-rules: 39
.219µs, path_prettifier: 39.024µs, skip_dirs: 31.36µs, cgo: 1.303µs, max_same_issues: 662ns, filename_unadjuster: 522ns, uniq_by_line: 271ns, fixer: 262
ns, skip_files: 247ns, diff: 204ns, sort_results: 191ns, source_code: 182ns, exclude: 182ns, severity-rules: 177ns, max_from_linter: 97ns, max_per_file_
from_linter: 66ns, path_shortener: 55ns, path_prefixer: 54ns                
INFO [runner] linters took 8.004349264s with stages: goanalysis_metalinter: 8.003284359s 
INFO File cache stats: 0 entries of total size 0B                           
INFO Memory: 82 samples, avg is 3258.7MB, max is 6761.6MB                   
INFO Execution took 8.290421183s                    


# Run go mod
.PHONY: vendor
Expand Down
22 changes: 0 additions & 22 deletions hack/goimports.sh

This file was deleted.