-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Inside if/else/end, rubocop complains about missing guard clause instead of extraneous return #2903
Comments
RuboCop wants: def positive?(number)
return true if number > 0
false
end |
This can be closed. |
@segiddins That's exactly the problem. Please notice that What I'm saying is that I find it odd that def positive?(number)
return true if number > 0
false
end over def positive?(number)
if number > 0
true
else
false
end
end |
Why don't you just write: def positive?(number)
number > 0
end |
Numbers, comparison, In general, I think this: def some_method(argument)
if condition?(argument)
return operation1(argument)
else
operation2(argument)
end
end should be turned into def some_method(argument)
if condition?(argument)
operation1(argument)
else
operation2(argument)
end
end instead of def some_method(argument)
return operation1(argument) if condition?(argument)
operation2(argument)
end |
I think @gregnavis's point is valid. Using the default configuration, both of the above mentioned alternatives are equally good. It's just that |
Any thoughts? If you think that def some_method(argument)
if condition?(argument)
operation1(argument)
else
operation2(argument)
end
end should be preferred then I might be able to spend time on contributing a patch. |
No, disable the |
@mikegee, I'm sorry for not being clear. My point was being able to continue using def some_method(argument)
if condition?(argument)
return operation1(argument)
else
operation2(argument)
end
end |
`Style/RedundantReturn` looks into conditional branches in order to find redundant `return`. E.g. the following will be flagged: def func if x return 1 else return 2 end end
`Style/RedundantReturn` looks into conditional branches in order to find redundant `return`. E.g. the following will be flagged: def func if x return 1 else return 2 end end
lib/kpm/database.rb:47:9: C: Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. if response.include?('Table') && response.include?('doesn\'t exist') I don't think the suggestion makes sense (apparently, I am not the only one: rubocop/rubocop#2903 (comment)
* Update externely outdated killbill client version * Bump kpm version for release * Update version for release * docker: Update KPM version in base image * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * docker: make the start command configurable via START_TOMCAT_OPTS Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * mention 4GB memory limit * Update README.adoc * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * docker: make Tomcat the main Docker process Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * spec: fix assertion Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: upgrade Docker images Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: handle special escape sequence \N{} Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * account: expand the source file To support things like ~. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * tasks: add KPM_DEBUG env variable to enable DEBUG logging Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix spec expectation Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * account: include reference_time in dates to fix Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: allow for blank DB passwords Make sure we never fallback to the default password. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: add Kaui playbook This also cleans up the Kaui role and associated configuration. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: update Kaui image to the latest base image Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: offline support Make sure kpm install is idempotent when a sha1 file is populated, even if no outbound networking is allowed. If force_download is specified however (false by default), network access to a Nexus instance is required. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * .circleci: clear cache Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: take into account force_download in KillbillServerArtifact#info Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: first pass at Flyway integration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: better idempotency checks for baseline Verified that if the schema_version table exists and is valid, Ansible doesn't detect any change. Verified that the task fails if the table exists and is invalid. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: improve migration errors handling Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: Flyway task cleanups and enhanced error handling Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: don't reinstall KPM unless needed Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: document Flyway feature Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: install Flyway in killbill image Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: docker: various cleanups Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: integrate kpm diagnostic Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * kpm: update version to 0.7.2 prior release Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: docker: update KPM to 0.7.2 Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: skip validations before migration If existing migrations have already been applied, Flyway will by default validate all of them before migrating. Our Ansible playbook however only downloads the delta of migrations to run, not the full history: so if there are existing migrations, the playbook would fail. Flyway has a flag ignoreMissingMigrations since 4.1.0, but our binary is still based on 4.0 and upgrading it is quite hard unfortunately. Luckily validateOnMigrate skips that validation as well, so it offers a good workaround for now. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * ansible: enable RemoteIpValve by default See discussion at killbill#147. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: make dispatching and complete queue threads configurable Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * ansible: make Reaper configurable Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * tomcat: add X-Request-Id to access logs * ansible: revisit JVM and Tomcat defaults Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * kpm: setup RuboCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/AlignArguments Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/AlignHash Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/EmptyLines Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/EmptyLinesAroundBlockBody Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/AccessModifierIndentation Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Layout/* Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix various Style cops Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix various auto-correct cops Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: RuboCop integration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: fix config Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: RuboCop iteration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: RuboCop iteration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: RuboCop iteration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: upgrade Kill Bill version Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: revisit JVM and Tomcat defaults Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: fix typo in README Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: make JVM properties configurable Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: use killbill/base:0.21.x Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: tag latest as latest-0.21.x Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: switch to 0.21.x images Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: RuboCop integration Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix regression on recent rubies Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: fix typo Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * circleci: fix typo Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RucoCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RucoCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RucoCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RucoCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RuboCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues reported by RuboCop Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix formatter regression String#% and format have two different signatures. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add tests for cpu_information Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add tests for disk_space_information Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add tests for memory_information Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add tests for entropy_available Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix specs on older Rubies Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add tests for os_information Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: update README with caching behavior Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: document diagnostic commands Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix Tomcat PID detection in system command This also cleans up the code a little bit. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add --as-json option to kpm inspect Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: refactor uninstaller in preparation for cleanup command Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add cleanup command Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * spec: cleanup sha1_checker_spec Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix issues with Nexus cache * Nexus cache should be cleaned when removing an entry in the sha1 registry * Nexus cache shouldn't index with LATEST Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix spec syntax for older rubies Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: add --version option to uninstall command Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix regressions in base_artifact_spec * Fix caching behavior with LATEST: since versions are always resolved in the sha1.yml, caching won't work anymore if LATEST is specified * Be more lenient with the expected networking error (sometimes it's a timeout, sometimes a socket error) Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: implement retries around Nexus operations Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove Litle entry This plugin was for Litle before the acquisition by Vantiv. The rebranding occurred in 2017 and integrating with the current version of Litle would require code changes. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-litle-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove logging entry The logging plugin (klogger) was an initial proof of concept for notification plugins written in Ruby. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-logging-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove currency entry The plugin isn't maintained anymore. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-currency-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove firstdata_e4 entry First Data recommends switching to the Payeezy RESTful APIs instead. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-firstdata-e4-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove payu_latam entry The plugin isn't maintained anymore. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-payu-latam-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove braintree_blue entry The plugin isn't maintained anymore (Blue and Orange platforms don't exist anymore). New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-braintree-blue-plugin and https://github.com/killbill/killbill-braintree-demo Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove zendesk entry The plugin isn't maintained anymore. New users shouldn't use this plugin. I've archived https://github.com/killbill/killbill-zendesk-plugin Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: clean legacy entries Remove entries for unsupported versions of Kill Bill. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix spec expectation Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * kpm: implement kpm info --as-json Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: trivial tweaks Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: glob support Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: improve docs Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * base_installer: RuboCop fix Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Account export: Add missing catalog_effective_date entry in DATE_COLUMNS_TO_FIX * Import account: Add support to import b64 encoded value for billing_events * Add instructions to make sure mysql LOAD_FILE works as expected * Rubocop offenses * README: document KAUI_CONFIG_DAO_ADAPTER property When using PostgreSQL, one needs to specify `KAUI_CONFIG_DAO_ADAPTER=postgresql` for Kaui. Otherwise, Kaui fails to start with the following error: ``` org.jruby.rack.RackInitializationException: No such file to load -- java.lang.StackOverflowError: null.rb ``` * Update plugins_directory.yml * Update plugins_directory.yml * kpm: better handling of large imports Verified we can import very large tables (100k+ rows). Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: be more lenient when importing data Ignore out of range errors for instance, in case the deployment has a slightly modified DDL. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * database: fix RuboCop warnings Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: remove bintray profile Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * plugins_directory: remove legacy require section Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: fix build image Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * directory: small regex fix No behavior change though. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: switch Maven url to HTTPS See https://support.sonatype.com/hc/en-us/articles/360041287334. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * kpm: prepare v0.8.0 release Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Revert "docker: tag latest as latest-0.21.x" This reverts commit 7248b09. * Revert "docker: tag latest as latest-0.21.x" This reverts commit 7248b09. * ansible: docker: updates for Kill Bill 0.22 Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: don't use 0.21.x base image anymore Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: fix modules with latest KPM version Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: add missing logger import in modules Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix regression on Ruby 2.2.x Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: prepare v0.8.1 release Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * kpm: fix tests Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * docker: install latest PostgreSQL bridge See also killbill#163. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * ansible: configure KPM bundle via environment properties Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugin_directory.xml for payment-test * docker: add missing KPM env variables in killbill Docker image Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * plugins_directory: re-introduce kpm entry for backward compatibility Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Update stripe version * Update payment-test version * kpm: force UTF-8 when opening files This is necessary for split to work when parsing UTF-8 data. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org> * Update plugins_directory.yml * Update plugins_directory.yml * Update plugins_directory.yml * Replace logback.xml in the ROOT.war archive (no more shared logback.xml) * Make tomcat \'webapps\' location configurable * Replace KAUI logback.xml in the ROOT.war archive (no more shared logback.xml) * Fix location where we unpack the ROOT.war * Fix permissions for the ROOT expanded directory * Update README.md * Ignore unknown tables when importing account dump file * Disable rubocop Style/Guard clause: lib/kpm/database.rb:47:9: C: Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. if response.include?('Table') && response.include?('doesn\'t exist') I don't think the suggestion makes sense (apparently, I am not the only one: rubocop/rubocop#2903 (comment) * Fix rubocop warnings Co-authored-by: stephane brossier <sbrossier@groupon.com> Co-authored-by: Pierre-Alexandre Meyer <pierre@mouraf.org> Co-authored-by: Victor Mokry <victor.mokry@uwhiz.co> Co-authored-by: Stéphane Brossier <stephane@kill-bill.org>
Rubocop behaves oddly on:
Expected behavior
Rubocop complains about unnecessary
return
statement.Actual behavior
Rubocop complains about missing guard clause.
Steps to reproduce the problem
Save the ruby snippet above in
test.rb
and runrubocop
. You'll see:RuboCop version
Include the output of
rubocop -V
:The text was updated successfully, but these errors were encountered: