Skip to content

chore: Remove varnamelen linter #854

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

Merged
merged 2 commits into from
Apr 4, 2022
Merged

chore: Remove varnamelen linter #854

merged 2 commits into from
Apr 4, 2022

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Apr 4, 2022

Golang prefers short var names in local scope. I think this is not idiomatic and excessive. I'd only assert this when the var exceeds local scope, but that is not supported.

https://github.com/golang/go/wiki/CodeReviewComments#variable-names

@Emyrk
Copy link
Member Author

Emyrk commented Apr 4, 2022

Also the linter doesn't say where the lint failure is"

  Error: variable name 'ui' is too short for the scope of its usage (varnamelen)
  Error: variable name 's' is too short for the scope of its usage (varnamelen)
  Error: variable name 'a' is too short for the scope of its usage (varnamelen)
  Error: variable name 'j' is too short for the scope of its usage (varnamelen)

https://github.com/coder/coder/runs/5818950685?check_suite_focus=true

@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #854 (25956e8) into main (f2a2126) will decrease coverage by 0.20%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #854      +/-   ##
==========================================
- Coverage   66.08%   65.87%   -0.21%     
==========================================
  Files         202      202              
  Lines       13209    13209              
  Branches       87       87              
==========================================
- Hits         8729     8702      -27     
- Misses       3597     3619      +22     
- Partials      883      888       +5     
Flag Coverage Δ
unittest-go- 65.21% <ø> (-0.29%) ⬇️
unittest-go-macos-latest 52.57% <ø> (+0.10%) ⬆️
unittest-go-ubuntu-latest 55.00% <ø> (ø)
unittest-go-windows-2022 51.71% <ø> (ø)
unittest-js 62.63% <ø> (ø)
Impacted Files Coverage Δ
codersdk/provisionerdaemons.go 58.46% <0.00%> (-6.16%) ⬇️
coderd/parameter/compute.go 74.07% <0.00%> (-4.45%) ⬇️
coderd/provisionerdaemons.go 58.51% <0.00%> (-4.05%) ⬇️
provisionerd/provisionerd.go 80.17% <0.00%> (-0.89%) ⬇️
coderd/database/queries.sql.go 83.30% <0.00%> (-0.23%) ⬇️
coderd/workspaceresources.go 62.19% <0.00%> (+1.62%) ⬆️
peer/conn.go 81.47% <0.00%> (+2.28%) ⬆️
provisionersdk/transport.go 85.10% <0.00%> (+6.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2a2126...25956e8. Read the comment docs.

Copy link
Contributor

@f0ssel f0ssel left a comment

Choose a reason for hiding this comment

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

I've never felt like our variable names in v1 were too short in my opinion.

I've had this bite me a few times, I think it's too sensitive. I agree with it in theory but it wouldn't let me use a single character variable for a 4 line middleware function. Idiomatic Go would say that is totally fine as long as it's not a super long function and doesn't leave scope.

I generally don't love using # of lines as the metric for this.

@johnstcn
Copy link
Member

johnstcn commented Apr 4, 2022

I'd prefer for us organic life forms to make the decision on this sort of thing.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

I've personally found this to be quite helpful in producing readable code. I think that edge-case of specific types matched with specific names can be helpful to declare.

It's an arbitrary position, but I'd rather have consistency with rw http.ResponseWriter over a mix of w and rw than the shorter name.

@kylecarbs
Copy link
Member

My comment doesn't need to block merge. Mostly everyone agrees, so if it becomes a problem we can add it back.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Didn't realize my request for change would block merge. Since everyone on the team seems to agree with this, I shall approve too.

@Emyrk Emyrk merged commit 4dd3c57 into main Apr 4, 2022
@Emyrk Emyrk deleted the stevenmasley/varnamelen branch April 4, 2022 16:17
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants