Skip to content
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

Check and change some of our current rubocop configuration #456

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 3 additions & 39 deletions .rubocop.yml
Expand Up @@ -29,21 +29,11 @@ Layout/LineLength:
- db/**/*

Layout/SpaceBeforeFirstArg:
Exclude:
- app/views/api/**/**/*
AllowForAlignment: true
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like having aligned comments, would this limit the ability of having multi line comments that are not aligned?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is for comments right? I think it's because in views we do

json.id         user.id
json.email      user.email
json.name       user.full_name
json.username   user.username

which I don't like but it is what it is 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed only for arguments, not comments. Layout::CommentIndentation would be the one that would modify comments


Lint/AmbiguousBlockAssociation:
AllowedMethods: change

Lint/BinaryOperatorWithIdenticalOperands:
Enabled: false

Lint/DeprecatedOpenSSLConstant:
Enabled: false

Lint/RaiseException:
Enabled: false

Comment on lines -38 to -46
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this rules being enabled by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do too

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

Metrics/AbcSize:
Max: 15
Exclude:
Expand Down Expand Up @@ -73,9 +63,6 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Max: 12

Rails/FilePath:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave this config

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. So you would leave it turned off?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave this disabled as well 😄


Rails/SaveBang:
Enabled: true

Expand All @@ -88,11 +75,9 @@ RSpec/MultipleExpectations:
RSpec/NamedSubject:
Enabled: false

Style/ArrayCoercion:
Enabled: true
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm 50/50 on this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my note, I removed it mainly because of the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with removing this


Style/BlockDelimiters:
EnforcedStyle: braces_for_chaining
Exclude:
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we remove this config for specs? Not saying I like the braces_for_chaining but even the default one is a good config to have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the idea

image

- spec/**/*

Style/Documentation:
Enabled: false
Expand All @@ -103,35 +88,14 @@ Style/ExpandPathArguments:
Style/GlobalStdStream:
Enabled: false

Style/HashEachMethods:
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this cop is unsafe I think it's a good idea to leave it in false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't know it was unsafe, do you have a link?

Copy link
Contributor

Choose a reason for hiding this comment

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

Enabled: false

Style/HashLikeCase:
MinBranchesCount: 4

Style/HashTransformKeys:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL I learned about transform_keys, but again since it can generate false positives I prefer no to enable it by default

Copy link
Member

Choose a reason for hiding this comment

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

https://docs.rubocop.org/rubocop/usage/auto_correct.html#safe-auto-correct

maybe we don't need to worry too much about the unsafe cops since we can use a safe autocorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also AutoCorrect: false so it never happens and it has to be a manual choice


Style/HashTransformValues:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Enabled: false

Style/ModuleFunction:
Enabled: false

Style/RedundantFetchBlock:
Enabled: false

Style/RedundantFileExtensionInRequire:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻


Style/RedundantRegexpCharacterClass:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻


Style/ReturnNil:
Enabled: true

Style/SlicingWithRange:
Copy link
Contributor

Choose a reason for hiding this comment

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

As same as above given the nature of false positives this has I would keep it disabled by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting my info from rubydoc.info which did not mention some of these false positives, I see docs.rubocop.org is better documented (as it should)

Enabled: false

Style/StringConcatenation:
Enabled: false
8 changes: 4 additions & 4 deletions config/puma.rb
Expand Up @@ -6,7 +6,7 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count

Expand All @@ -17,14 +17,14 @@

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch('PORT') { 3000 }
port ENV.fetch('PORT', 3000)

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch('RAILS_ENV') { 'development' }
environment ENV.fetch('RAILS_ENV', 'development')

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
Expand Down