Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Joibel
Copy link
Member

@Joibel Joibel commented Jan 29, 2026

Motivation

Enables the gocritic linter for better and more reliable code

Modifications

  • ifElseChain (~30): Converted if-else chains to switch statements
  • deprecatedComment (~7): Fixed DEPRECATED: → Deprecated: with proper paragraph separation
  • elseif (~6): Flattened else { if ... } → else if ...
  • underef (~8): Simplified (*ptr).field → ptr.field
  • assignOp (~4): Changed x = x + 1 → x++ and x = x + y → x += y
  • appendAssign (~3): Used slices.Concat instead of append to different variable
  • singleCaseSwitch (~5): Converted single-case switches to if statements
  • sloppyLen (~3): Changed len(x) <= 0 → len(x) == 0
  • badCond (~4): Fixed suspicious conditions in tests
  • commentFormatting (~2): Added space after //
  • unlambda (~2): Simplified lambdas to direct function references
  • regexpMust (~2): Used regexp.MustCompile for constant patterns
  • valSwap (~1): Used tuple swap a, b = b, a
  • exitAfterDefer (~1): Restructured to ensure defers run before os.Exit
  • offBy1 (~1): Fixed potential -1 index issue
  • captLocal (~1): Fixed capitalization of local variable
  • mapKey (~1): Removed trailing whitespace from map key

The comment changes cause a comment only CRD change.

Verification

CI checks

Documentation

None required

@Joibel Joibel requested a review from terrytangyuan as a code owner January 29, 2026 10:01
@Joibel Joibel added the area/contributing Contributing docs, ownership, etc. Also devtools like devcontainer and Nix label Jan 29, 2026
)

func main() {
os.Exit(run())
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the exitAfterDefer fix

slashDotDotSlash := fmt.Sprintf(`%c..%c`, os.PathSeparator, os.PathSeparator)
if strings.Contains(path, slashDotDotSlash) {
safeDir = path[:strings.Index(path, slashDotDotSlash)]
if idx := strings.Index(path, slashDotDotSlash); idx >= 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.

The linter can't prove to itself that the two calls to the regexp won't work on different strings in the previous version.

@Joibel Joibel force-pushed the gocritic branch 3 times, most recently from 016cfb5 to 48f40b6 Compare January 29, 2026 11:17
@Joibel Joibel enabled auto-merge (squash) January 29, 2026 12:01
@Joibel Joibel merged commit 1a8ed83 into argoproj:main Jan 29, 2026
39 checks passed
@Joibel Joibel deleted the gocritic branch January 29, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/contributing Contributing docs, ownership, etc. Also devtools like devcontainer and Nix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants