Skip to content

Use linter goheader to ensure license header exists#5435

Merged
Warashi merged 3 commits intomasterfrom
golangci-lint-goheader
Dec 20, 2024
Merged

Use linter goheader to ensure license header exists#5435
Warashi merged 3 commits intomasterfrom
golangci-lint-goheader

Conversation

@Warashi
Copy link
Member

@Warashi Warashi commented Dec 19, 2024

What this PR does:

  • enable goheader within the golangci-lint's config
  • fix the warnings

Why we need it:

To ensure the license header exists

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
@Warashi
Copy link
Member Author

Warashi commented Dec 19, 2024

I ran make lint/go and got the result below.

❯ make lint/go
docker run --rm -e GOCACHE=/repo/.cache/go-build -e GOLANGCI_LINT_CACHE=/repo/.cache/golangci-lint -v /home/warashi/ghq/github.com/pipe-cd/pipecd:/repo -w /repo -it golangci/golangci-lint@sha256:4e53bfe25ef2f1e14a95da42d694211080f40d118730541ce1513a83cf7587ec  golangci-lint run -v
INFO golangci-lint has version 1.62.2 built with go1.23.3 from 89476e7a on 2024-11-25T14:16:01Z 
INFO [config_reader] Config search paths: [./ /repo / /root] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 12 linters: [depguard gocritic goheader goimports gosimple ineffassign misspell prealloc staticcheck stylecheck unconvert unparam] 
INFO [loader] Go packages loading at mode 8767 (compiled_files|deps|files|exports_file|imports|name|types_sizes) took 969.506346ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 73.593529ms 
INFO [linters_context/goanalysis] analyzers took 0s with no stages 
INFO [runner/skip_dirs] Skipped 39 issues from dir pkg/app/piped/executor/analysis/mannwhitney by pattern pkg/app/piped/executor/analysis/mannwhitney 
INFO [runner] Issues before processing: 933, after processing: 0 
INFO [runner] Processors filtering stat (in/out): identifier_marker: 412/412, exclude-rules: 412/4, cgo: 933/933, path_prettifier: 933/933, invalid_issue: 933/933, autogenerated_exclude: 815/412, exclude: 412/412, skip_files: 933/854, skip_dirs: 854/815, filename_unadjuster: 933/933, nolint: 4/0 
INFO [runner] processing took 24.417009ms with stages: exclude-rules: 7.225086ms, autogenerated_exclude: 5.916751ms, identifier_marker: 5.327876ms, path_prettifier: 2.180793ms, nolint: 1.832417ms, skip_dirs: 1.165792ms, skip_files: 680.917µs, cgo: 34.417µs, invalid_issue: 33.833µs, filename_unadjuster: 14.792µs, max_same_issues: 1.167µs, sort_results: 834ns, diff: 500ns, uniq_by_line: 375ns, exclude: 332ns, fixer: 292ns, max_from_linter: 250ns, max_per_file_from_linter: 167ns, source_code: 167ns, path_shortener: 84ns, path_prefixer: 84ns, severity-rules: 83ns 
INFO [runner] linters took 310.10779ms with stages: goanalysis_metalinter: 285.621823ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 15 samples, avg is 47.3MB, max is 128.6MB 
INFO Execution took 1.356511334s             

// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
Copy link
Member Author

Choose a reason for hiding this comment

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

changed hard tabs to spaces

// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without this empty line, gofmt converts heading spaces to tabs because they are treated as godoc comments

@Warashi Warashi marked this pull request as ready for review December 19, 2024 07:07
@codecov
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.08%. Comparing base (17a5007) to head (25249b6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5435      +/-   ##
==========================================
- Coverage   26.10%   26.08%   -0.02%     
==========================================
  Files         451      451              
  Lines       48837    48837              
==========================================
- Hits        12748    12741       -7     
- Misses      35072    35078       +6     
- Partials     1017     1018       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

Nice added 👍

@Warashi Warashi enabled auto-merge (squash) December 19, 2024 07:30
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

🚀

@Warashi Warashi merged commit 314ce3a into master Dec 20, 2024
@Warashi Warashi deleted the golangci-lint-goheader branch December 20, 2024 00:42
@github-actions github-actions bot mentioned this pull request Jan 21, 2025
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants