Go-tools: Investigate go-critic checks

Created on 30 Jul 2018  ·  3Comments  ·  Source: dominikh/go-tools

https://go-critic.github.io/overview
Last update (of this issue): Wed Jan 13 05:49:01 AM CET 2021

Consider implementing

Already implemented

  • caseOrder
  • defaultCaseOrder
  • typeSwitchVar
  • yodaStyleExpr
  • equalFold
  • dupSubExpr
  • badCall
  • dupImport
  • badLock

Not desirable

  • builtinShadow
  • initClause
  • docStub
  • emptyFallthrough
  • emptyStringTest
  • rangeExprCopy
  • rangeValCopy
  • octalLiteral
  • commentFormatting
  • commentedOutImport
  • paramTypeCombine
  • codegenComment
  • commentedOutCode
  • assignOp
  • sloppyReassign
  • wrapperFunc
  • typeUnparen
  • nestingReduce
  • hugeParam
  • badCond
  • deprecatedComment
  • methodExprCall
  • unlabelStmt
  • unnecessaryBlock
  • regexpPattern
  • whyNoLint
  • mapKey
  • badRegexp
  • ruleguard
  • sortSlice
  • sqlQuery
  • unnecessaryDefer

Undecided

  • filepathJoin
  • typeDefFirst
new-check research

All 3 comments

I think initClause fits stylecheck more, because it's not really a simplification, but rather an effort of avoiding code with surprises.

singleCaseSwitch can benefit from TODO comments checks.
Some switches with a single case have something like: "TODO: cover all things later".
These may be better left alone, at least by default.
This case is not handled by gocritic since it's not really convenient to match comments (non-doc comments) to arbitrary statement.

elseif finds many cases where code can be less beautiful when re-written.
See https://github.com/go-critic/go-critic/issues/420.
I don't know whether my approach gives good enough reduce in these false-positive like cases.
There can be issues in determining 100%-fine replacements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

axcdnt picture axcdnt  ·  3Comments

dominikh picture dominikh  ·  3Comments

MarkSonghurst picture MarkSonghurst  ·  4Comments

Jacalz picture Jacalz  ·  4Comments

dominikh picture dominikh  ·  3Comments