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

Add flag to golangci-lint to show line number if there is error #6096

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

lubronzhan
Copy link
Contributor

Fix #6095
Example run after adding the change in my PR
#6073
projectcontour/contour/actions/runs/7551166827/job/20557981226?pr=6073

run golangci-lint
  Running [/home/runner/golangci-lint-1.55.2-linux-amd64/golangci-lint run --out-format=github-actions --build-tags=e2e,conformance,gcp,oidc,none --out-${NO_FUTURE}format=colored-line-number] in [] ...
  Error: internal/provisioner/objects/rbac/role/role.go:100:45: unused-parameter: parameter 'namespace' seems to be unused, consider removing or renaming it as _ (revive)
  func desiredRoleForContourInNamespace(name, namespace string, contour *model.Contour) *rbacv1.Role {
                                              ^
  Error: internal/provisioner/objects/rbac/role/role.go:117:121: updateRoleIfNeeded - result 0 (*k8s.io/api/rbac/v1.Role) is never used (unparam)
  func updateRoleIfNeeded(ctx context.Context, cli client.Client, contour *model.Contour, current, desired *rbacv1.Role) (*rbacv1.Role, error) {
                                                                                                                          ^
  Error: issues found

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
@lubronzhan lubronzhan requested a review from a team as a code owner January 17, 2024 04:56
@lubronzhan lubronzhan requested review from tsaarni and sunjayBhatia and removed request for a team January 17, 2024 04:56
@sunjayBhatia sunjayBhatia requested review from a team, davinci26 and clayton-gonsalves and removed request for a team January 17, 2024 04:57
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (572515a) 78.85% compared to head (9d59072) 78.85%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6096   +/-   ##
=======================================
  Coverage   78.85%   78.85%           
=======================================
  Files         138      138           
  Lines       19731    19731           
=======================================
  Hits        15558    15558           
  Misses       3870     3870           
  Partials      303      303           

Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

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

Thanks @lubronzhan! This seems the way to go, though I cannot figure out why this is not the default, as discussed at length here golangci/golangci-lint-action#119

By default golangci-lint-action runs golangci-lint with --output-format=github-action. When user gives --out-format=colored-line-number the format will be concatenated and result will be both --out-format=github-actions,colored-line-number (according to golangci/golangci-lint-action#769) giving best of both worlds: annotations (annotations.png from workflow commands) as well as line numbers in logs!

.github/workflows/prbuild.yaml Outdated Show resolved Hide resolved
changelogs/unreleased/6095-lubronzhan-small.md Outdated Show resolved Hide resolved
@skriss skriss added the release-note/none-required Marks a PR as not requiring a release note. Should only be used for very small changes. label Jan 17, 2024
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM

@skriss skriss merged commit 61b6fae into projectcontour:main Jan 17, 2024
26 checks passed
@lubronzhan lubronzhan deleted the topic/lubron/fix-6095 branch January 17, 2024 21:34
@lubronzhan lubronzhan restored the topic/lubron/fix-6095 branch January 17, 2024 21:34
@lubronzhan lubronzhan deleted the topic/lubron/fix-6095 branch January 17, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/none-required Marks a PR as not requiring a release note. Should only be used for very small changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

golangci-lint is not showing line number for error
4 participants