k6 icon indicating copy to clipboard operation
k6 copied to clipboard

Fix inter issues in `master` branch

Open na-- opened this issue 7 years ago • 1 comments

What?

We should fix the linter issues that exist in our master branch.

### Tasks
- [ ] Fix 231 issues in js/modules/k6/html
- [ ] https://github.com/grafana/k6/pull/3566
- [ ] [Fix 51 issues in lib](https://github.com/grafana/k6/pull/3561)
- [ ] Fix 22 issues in cloudapi
- [ ] Fix 39 issues in metrics
- [ ] Fix rest of the packages
- [ ] https://github.com/grafana/k6/pull/3495
- [ ] https://github.com/grafana/k6/pull/3484
- [ ] https://github.com/grafana/k6/pull/3482
- [ ] https://github.com/grafana/k6/pull/3460
- [ ] https://github.com/grafana/k6/pull/3463
- [ ] https://github.com/grafana/k6/pull/3479
- [ ] https://github.com/grafana/k6/pull/3481
- [ ] https://github.com/grafana/k6/pull/3462
- [ ] https://github.com/grafana/k6/pull/3480
- [ ] https://github.com/grafana/k6/pull/3485
- [ ] https://github.com/grafana/k6/pull/3483
- [ ] https://github.com/grafana/k6/pull/3478

Right now we use the golangci-lint as the main tool for linting. The latest report:

golangci-lint run --out-format=tab | awk 'NF { print $1 }' | sed -E 's|/[^/]*(:[0-9]+){0,2}$||' | uniq -c | sort -rn
 233 js/modules/k6/html
    112 js/modules/k6/http
     48 lib
     38 metrics
     32 lib/executor
     28 lib/netext/httpext
     26 lib/netext
     22 cloudapi
      5 lib/fsext
      5 lib
      3 output/statsd
      3 output/json
      3 js/modules/k6/grpc
      2 lib/types
      2 lib/netext/grpcext
      2 lib/consts
      2 js/modules/k6/metrics
      2 js/common
      2 cmd

Why?

Most of those are about undocumented methods or using underscores or ALL_CAPS in variables, but it's still worth it to spend some time and eliminate, or at least substantially reduce, the number of linter complaints.

Fixing linter issues would significantly help any potential contributors because:

  • it forces best practices
  • it would force us to improve the in-code documentation, tremendously helping new people who are unfamiliar with the codebase
  • it would make the code more idiomatic
  • a lot of Go editors have golint/golangci-lint automatically enabled, and when you open some files with them, there are dozens of issues reported
  • we can improve our Go report card score, after all we've added it in the top of the README...
  • and many more

na-- avatar Sep 14 '18 12:09 na--

This tool might be helpful for some of the drudge work: https://github.com/cuonglm/gocmt

na-- avatar Jul 19 '19 14:07 na--