-
Notifications
You must be signed in to change notification settings - Fork 207
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
Adding rubocop sample config #547
Conversation
There are too many results to compare View more on Code Climate. |
Some important options which I think we need to add:
|
b0549f9
to
d211cd5
Compare
Done in https://github.com/publiclab/mapknitter/pull/547/files#diff-11a0d7906801d9dea0eccb85667ad811R125 and I have removed the line which enforces double quotes. |
Codecov Report
@@ Coverage Diff @@
## main #547 +/- ##
==========================================
- Coverage 71.27% 70.17% -1.11%
==========================================
Files 33 34 +1
Lines 1295 1321 +26
==========================================
+ Hits 923 927 +4
- Misses 372 394 +22
|
So is this still wanted @jywarren @SidharthBansal @sashadev-sky @icarito @cesswairimu ? |
@alaxalves I looked through the configs. So just to confirm, the files listed under "Exclude" are actually the ones that will be copped because they are excluded from being disabled? One thing I think is good practice is to use the same rubocop rules across repos whenever possible. Should we instead be copying over the config files from plots2, and customizing from there if necessary? Then also anything that is decided to be too strict we could also remove from plots2. |
@sashadev-sky The files in exclude are not compiled by Rubocop thus those files are not "judged". It's a good option having the same config provided in Plots2, so I'll use the configs set there. |
@alaxalves gotchya! Ok ping me again when its updated |
It's done. BTW it was a great idea using the same rules as in Plots2. Thnx for the tip @sashadev-sky |
The shopify style guide is quite huge. Did you test this and see how many offenses it generates on the current codebase? |
Just ping me when this is ready for a merge, thanks everyone!!! 🙌 |
@jywarren @kaustubh-nair @sashadev-sky I'm currently working on those offenses, but there are a lot rn (~30). By this friday I'll get it done. |
@alaxalves I didn't really go through the shopify style guide properly, but if it is too strict we should not be enforcing it. |
@kaustubh-nair @alaxalves Ok how about we start with the ones that are failing here - 22 issues to fix we can decide based on these what should be fixed and what we should stop copping for because its too strict. -- update just saw @alaxalves is on this so ty 👍 The problem is can you guys see which mistakes specifically are being caught? For me it says cannot generate report because of high volume. Then @kaustubh-nair we can just move this over to one of your PRs if you're having too many unreasonable codeclimate issues still and decide again what is too strict and remove it.. just deal with it as it comes up I think before there were 80+ issues to fix on this PR so this file can't be that unreasonable right? It has worked for plots2 for a while |
app/models/map.rb
Outdated
end | ||
|
||
def self.authors(limit = 50) | ||
Map.limit(limit) | ||
.order("maps.id DESC") | ||
.where('password = "" AND archived = "false"') | ||
.collect(&:author) | ||
# .group("maps.author") | ||
# .group("maps.author") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we delete this commented line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
else | ||
output = 'export has not been run' | ||
end | ||
output = if export.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if result.successful? | ||
@user = User.find_by_identity_url(identity_url) | ||
if not @user | ||
unless @user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanted, I think you could use the not-not here and maybe other places (it is good practice as far as I know), like this:
!!@user
The first ! is to turn nill into true and the second ! is to turn true into false.
app/models/map.rb
Outdated
total_sum = (scales.inject {|sum, n| sum + n }) if scales | ||
average = total_sum/count if total_sum | ||
total_sum = (scales.inject { |sum, n| sum + n }) if scales | ||
average = total_sum / count if total_sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it is the case here, but I guess it is worth mentioning. I was taking much longer reviewing PRs at work because of different settings for formatting on save in the code editors, so people kept doing and undoing space changes. If that is the case, it would be great to define a standard, or format code with some other tool :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rules such as Layout/SpaceAroundBlockParameters
, Layout/SpaceAroundEqualsInParameterDefault
, Layout/SpaceAroundOperators
and more try to define such spacing rules. The thing is that after we merge this we should quickly integrate this with our pipeline to encourage contributors to use our code pattern. Otherwise problems such as you're described will keep happening.
@alaxalves what's the progress here? anything I can do to help? |
Hi @sashadev-sky. I'm currently trying to adjust Mapknitter's code into our rubocop rules(took from Plots2). There are around <15 failling offenses. |
Can you not see what specifically the offences are? It won't generate a report for me |
|
I looked over two of them - hope this helps!
I think you might also need to update your main branch and rebase again because I saw a few files under "files changed" that were updated from past merged PRs |
Co-Authored-By: Sasha Boginsky <41092741+sashadev-sky@users.noreply.github.com>
@sashadev-sky Good news is that I have finished fixing these offenses, I think it's ready to merge. PS: CodeClimate is set waaay different from Rubocop. I think we could keep only Rubocop, since CC lastest version doesn't support Rubocop linting version > 0.52.0, along with the performance cop. And it produces 'fake' errors such as: .rubocop.yml: Layout/EndAlignment has the wrong namespace - should be Lint
.rubocop.yml: Layout/DefEndAlignment has the wrong namespace - should be Lint
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:122:in `require': cannot load such file -- rubocop-performance (LoadError)
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:122:in `require'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:11:in `each'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader.rb:38:in `load_file'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:87:in `block in base_configs'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:86:in `map'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:86:in `base_configs'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader_resolver.rb:21:in `resolve_inheritance'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader.rb:44:in `load_file'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_loader.rb:79:in `configuration_from_file'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config_store.rb:44:in `for'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:161:in `excluded_dirs'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:139:in `find_files'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:112:in `target_files_in_dir'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:89:in `block in find'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:87:in `each'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/target_finder.rb:87:in `find'
from /usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/runner.rb:58:in `find_target_files'
from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
from /usr/src/app/lib/cc/engine/rubocop.rb:49:in `files_to_inspect'
from /usr/src/app/lib/cc/engine/rubocop.rb:29:in `block in run'
from /usr/src/app/lib/cc/engine/rubocop.rb:28:in `chdir'
from /usr/src/app/lib/cc/engine/rubocop.rb:28:in `run'
from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>' |
@alaxalves So what do you think should be done about codeclimate? |
That's a good option. I'll test it out by locking rubocop on this version. Thnx. |
@kaustubh-nair Just did that but I'm not being able to see the CC offenses. |
Great! Do we need to make a note to not accept dependabot PRs for rubocop then? |
Thank you!!!!!! |
Yes, otherwise CodeClimate will start breaking. Thx @jywarren |
* Add annotation tests and remove redundant code * Add export tests * Remove some code * Fix codeclimate issues * Fix codeclimate issues * Fix rubocop block length * Removing rubocop cfg since #547 and renaming tests
* Adding rubocop sample config * Removing double_quotes enforcement * Using same rubocop yaml as in Plots2 * Autofixing rubocop offenses * Fixing conditions for CC Co-Authored-By: Sasha Boginsky <41092741+sashadev-sky@users.noreply.github.com> * Adding Performance cop and fixing some offenses * Fixing rubocop offenses and warnings * Downgrading rubocop version since publiclab#547 (comment)
* Add annotation tests and remove redundant code * Add export tests * Remove some code * Fix codeclimate issues * Fix codeclimate issues * Fix rubocop block length * Removing rubocop cfg since publiclab#547 and renaming tests
Fixes #543 (comment) (<=== Add issue number here)
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Thanks!