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

increase lint max line-length #2178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

fridrik01
Copy link
Contributor

@fridrik01 fridrik01 commented Nov 25, 2024

Currently running make lint runs linting according to the .golangci.yaml conf. In that file we set a max line-length of 80 which outputs linting errors for lines longer than that and results in failed CI.

I propose we increase that limit to at least 120 as it allows more code to be viewed on screen at once as we usually have more horizontal screen space than vertical. Go is also typically not strict on line length.

I would be fine with having no upper limit and make it up to the developer to make sure their code is readable, but lets start with this to get a discussion going.

This comment was marked as abuse.

@fridrik01 fridrik01 marked this pull request as ready for review November 25, 2024 17:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range comments (2)
.golangci.yaml (2)

Line range hint 391-408: Consider a more moderate increase for max-same-issues

The increase from 3 to 50 for max-same-issues is significant. While this reduces noise, it might mask systematic issues that should be addressed.

Consider:

  1. A more moderate value (e.g., 10-20)
  2. Adding a comment explaining why 50 was chosen
  3. Creating separate limits for different linters
   # Maximum count of issues with the same text.
   # Set to 0 to disable.
   # Default: 3
+  # Increased to allow for common patterns across the codebase
+  # TODO: Consider reducing this value after addressing current issues
   max-same-issues: 50

Line range hint 1-408: Consider splitting the configuration file

The configuration file is becoming quite large and complex. Consider splitting it into multiple files for better maintainability:

  • golangci.base.yaml: Base configuration
  • golangci.linters.yaml: Linter-specific settings
  • golangci.rules.yaml: Exclusion rules and thresholds

This would make it easier to manage and review changes to specific aspects of the linting configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 86b41a4 and 1c532dc.

📒 Files selected for processing (1)
  • .golangci.yaml (2 hunks)
🔇 Additional comments (2)
.golangci.yaml (2)

Line range hint 44-71: LGTM on exhaustruct exclusions

The exclusion patterns are well-chosen and documented:

  • Standard library exclusions cover common HTTP and OS packages
  • Third-party exclusions focus on widely-used testing and infrastructure packages

Line range hint 8-11: LGTM on timeout increase, but monitor CI pipeline duration

The increase from 1m to 3m is reasonable for thorough analysis, especially with the extensive list of enabled linters.

Let's check the CI logs to ensure this doesn't significantly impact pipeline duration:

✅ Verification successful

Timeout increase to 3m in golangci-lint configuration is reasonable

The timeout increase from 1m to 3m is a sensible configuration change that allows for more thorough analysis, especially with multiple linters enabled. While we couldn't verify the exact impact on CI duration, this is a common and safe timeout value for medium to large codebases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check recent CI job durations to assess impact
gh run list --limit 10 --workflow lint.yml --json durationMS,conclusion \
  | jq -r '.[] | "\(.conclusion): \(.durationMS/1000)s"'

Length of output: 364


Script:

#!/bin/bash
# Let's try a different approach to check CI workflow durations
gh run list --limit 10 --workflow lint.yml --json startedAt,conclusion,updatedAt \
  | jq -r '.[] | "\(.conclusion): \(if .startedAt != null and .updatedAt != null then (((sub((.updatedAt | fromdateiso8601), (.startedAt | fromdateiso8601)))/60)) else "N/A" end) minutes"'

Length of output: 699

.golangci.yaml Show resolved Hide resolved
@fridrik01 fridrik01 self-assigned this Nov 25, 2024
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.42%. Comparing base (86b41a4) to head (1c532dc).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2178       +/-   ##
===========================================
+ Coverage   26.34%   40.42%   +14.07%     
===========================================
  Files         361        4      -357     
  Lines       16297       47    -16250     
  Branches       12       12               
===========================================
- Hits         4294       19     -4275     
+ Misses      11732       28    -11704     
+ Partials      271        0      -271     

see 357 files with indirect coverage changes

---- 🚨 Try these New Features:

Copy link

@Gabrielcdecarvalho Gabrielcdecarvalho left a comment

Choose a reason for hiding this comment

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

@@ -147,7 +147,7 @@ linters-settings:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length: 150 # Increased maximum line length.
# Tab width in spaces.
# Default: 1
tab-width: 1

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.

2 participants