go-critic.github.io

Trophies

Contributions are partitioned by projects.

By “contribution”, we mean all of these:

  1. Commit that fixes the problem
  2. Reported issue (if there is no commit yet)
  3. Any other form of advices that were suggested by go-critic

The list is sorted by priority. If commit exist, it should be referenced instead of issue. If issue exist, is should be referenced (as opposed of 3 where we have no explicit issue ticket).

This page exists mostly to determine most useful checks that can trigger on real projects. These checks are a good candidates to be included into “default” go-critic list.

Most projects listed here have high base code quality, so every detected issue counts.

golang/go

  1. net: combine append calls in reverseaddr appendCombine
  2. cmd/link/internal/ld: avoid Reloc copies in range loops rangeValCopy
  3. cmd/compile/internal/ssa: fix partsByVarOffset.Less method dupSubExpr
  4. runtime: remove redundant explicit deref in trace.go underef
  5. cmd/link/internal/sym: uncomment code for ELF cases in RelocName commentedOutCode
  6. runtime: simplify slice expression to sliced value itself unslice
  7. html/template: use named consts instead of their values namedConst
  8. cmd/internal/obj/arm64: simplify some bool expressions boolExprSimplify
  9. math,net: omit explicit true tag expr in switch switchTrue
  10. archive/tar: remore redundant parens in type expressions typeUnparen
  11. strings, bytes: avoid unnecessary function literals unlambda

upspin/upspin

  1. pack/internal/packtest: remove redundant parens in type conv typeUnparen

gobufallo/buffalo

  1. internal/release,render: remove redundant func wrapping unlambda
  2. buffalo/cmd: make len comparison more clear sloppyLen

graphql-go/graphql

  1. use type switch with var binding typeSwitchVar
  2. replace regexp.Compile with regexp.MustCompile regexpMust
  3. replace len(x)<=v with len(x)==v sloppyLen
  4. simplify single case type switches singleCaseSwitch
  5. simplify assignments with op= syntax assignOp

coreos/etcd

  1. etcdctl/ctlv2/command: fix type switch case order caseOrder
  2. etcdserver/api/v2discovery: simplify !(x == y) to x != y boolExprSimplify
  3. contrib/recipes: use clientv3.NoLease instead of 0 namedConst

openshift/origin

  1. cmd/server: replace raw literals with named constants namedConst
  2. apps: replace func lits with wrapped func value unlambda
  3. build/controller/build: simplify bool exprs boolExprSimplify

mvdan/sh

  1. interp: avoid redundant array copies rangeExprCopy
  2. interp,syntax: replace single case switches singleCaseSwitch
  3. syntax: replace if-else chains with expr switch stmt ifElseChain

securego/gosec

  1. replace len(x)<=0 with len(x)==0 sloppyLen
  2. fix duplicated index issue in Less method dupSubExpr

go-reform/reform

  1. parse: replace 1 case switch with if singleCaseSwitch

rumyantseva/go-zeroservice

  1. app.go: rename unused param to _ unusedParam

intel-go/nff-go

  1. Modified style in merge function typeSwitchVar, paramTypeCombine

afiskon/go-elector

  1. minor style fixes ifElseChain, stdExpr, paramTypeCombine

minio/minio

  1. simplifying if-else chains to switches singleCaseSwitch

ethereum/go-ethereum

  1. all: avoid copying arrays in loops rangeExprCopy
  2. dashboard: append to proper slice appendAssign
  3. all: simplify switches singleCaseSwitch, typeSwitchVar

google/go-github

  1. Remove redundant dereference of time.Time underef
  2. fix named consts namedConst

google/go-cloud

  1. all: simplify and clarify some expressions boolExprSimplify, typeSwitchVar, ifElseChain, namedConst

ncw/rclone

  1. all: fix go-critic linter suggestions undered, namedConst, unslice, builtinShadow, typeUnparen

go-gitea/gitea

  1. Remove check for negative length sloppyLen
  2. Use named const instead of a raw string namedConst
  3. Use type switch typeSwitchVar
  4. Remove duplicated if bodies dupBranchBody
  5. Make switch more clear defaultCaseOrder