-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rubocop fixes and configuration update #19218
Conversation
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
f9c0cf7
to
0f28056
Compare
a195b05
to
bae6cdb
Compare
Generated by 🚫 dangerJS |
bae6cdb
to
7f070cc
Compare
7f070cc
to
666fcad
Compare
666fcad
to
945e708
Compare
a10a127
to
946ab0b
Compare
fe688cb
to
c5d00d5
Compare
1675bc3
to
2ba7613
Compare
f123b73
to
37809c8
Compare
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.
Thank you for tackling RuboCop @iangmaia !
Before moving forward with this, I suggest syncing with @spencertransier . He's been working on removing outdated settings, like GHHELPER_REPO
, from other projects. I wouldn't be surprised if this one was next in the list. It'd be a shame if you worked in parallel and generated merge conflicts
### Gems needed only for generating Promo Screenshots | ||
group :screenshots, optional: true do | ||
gem 'rmagick', '~> 4.1' | ||
gem 'rmagick', '~> 4.1' | ||
end |
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.
@iangmaia 😄 🤖 win!
fastlane/Fastfile
Outdated
@@ -160,7 +162,7 @@ import 'lanes/release_management_in_ci.rb' | |||
|
|||
default_platform(:android) | |||
|
|||
before_all do |lane| | |||
before_all do |_lane| |
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 believe RuboCop prefixed this with _
because it's unused. But if that's the case, we might as well remove it, no?
before_all do |_lane| | |
before_all do |
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.
Yes, this was auto-fixed by RuboCop.
In principle I agree, but at the same time, the signature does help to document that this is a special Fastlane thing 🤔
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.
My two cents are that it's up to us devs to look into the documentation to discover what optional parameters the method we use have. I prefer the code to be leaner, every unused parameter begs the question "why is this here?"
But, not something I feel so strongly about to delay this PR for it.
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.
True, the _
RuboCop requests brings in a bit more obscurity to the fact parameter is there. Decided to go with your suggestion: cc10f9d
fastlane/Fastfile
Outdated
@@ -48,8 +50,8 @@ fastlane_require 'dotenv' | |||
USER_ENV_FILE_PATH = File.join(Dir.home, '.wpandroid-env.default') | |||
Dotenv.load(USER_ENV_FILE_PATH) | |||
|
|||
ENV[GHHELPER_REPO = 'wordpress-mobile/WordPress-Android'] | |||
ENV['PROJECT_ROOT_FOLDER'] = File.dirname(File.expand_path(__dir__)) + '/' | |||
ENV.fetch(GHHELPER_REPO = 'wordpress-mobile/WordPress-Android', nil) |
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'm not sure about this change.
I think what the code did (or tried to do) before was setting the GHHELPER_REPO
value in the environment. Now it's only reading it, I think. 🤔
By the way, do we even need it in the environment? I thought we removed it a while back. See wordpress-mobile/WordPress-iOS#20072
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.
This went away with the latest rebase, so I believe @spencertransier already worked on some refactoring here.
It seems that the old code and the RuboCop updated code weren't doing much 😅
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 believe @spencertransier already worked on some refactoring here.
I thought that, too, but couldn't find the PR. I've seen many of those recently because Spencer has been busy across all our apps and assumed I just got confused.
fastlane/lanes/build.rb
Outdated
unless options[:skip_confirm] | ||
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?') | ||
end | ||
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?') |
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.
What do you think of using positive logic here and in the other instances?
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?') | |
UI.user_error!('Aborted by user request') unless options[:skip_confirm] || UI.confirm('Do you want to continue?') |
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.
Ah, nice one. RuboCop changed it to avoid nesting, I believe, but the unless
with a positive condition is more readable. Updated here: 407518f
57fe61a
to
ec62a0b
Compare
Good point -- in fact, I already had quite some conflicts on several (including this one) of the open PRs in the apps, for both Dangermattic and RuboCop config. Hopefully we'll merge the PRs soon and it will be easier when all branches are aligned on RuboCop and Ruby 3 setup. |
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.
Approved with non blocking syntax sugar suggestions
fastlane/Fastfile
Outdated
@@ -160,7 +162,7 @@ import 'lanes/release_management_in_ci.rb' | |||
|
|||
default_platform(:android) | |||
|
|||
before_all do |lane| | |||
before_all do |_lane| |
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.
My two cents are that it's up to us devs to look into the documentation to discover what optional parameters the method we use have. I prefer the code to be leaner, every unused parameter begs the question "why is this here?"
But, not something I feel so strongly about to delay this PR for it.
@@ -158,7 +154,7 @@ | |||
rescue FastlaneCore::Interface::FastlaneError => e | |||
# Sometimes the upload fails randomly with a "Google Api Error: Invalid request - This Edit has been deleted.". | |||
# It seems one reason might be a race condition when we do multiple edits at the exact same time (WP beta, JP beta). Retrying usually fixes it | |||
if e.message.start_with?('Google Api Error') && (retry_count -= 1) > 0 | |||
if e.message.start_with?('Google Api Error') && (retry_count -= 1).positive? |
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.
TIL. Nice!
fastlane/lanes/release.rb
Outdated
end rescue puts "Cannot delete file #{file}" | ||
File.delete(file) if Integer(File.basename(file, '.*')) < Integer(options[:build]) | ||
rescue StandardError | ||
puts "Cannot delete file #{file}" |
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.
Out of scope, but what do you think of relying on Fastlane's UI management?
puts "Cannot delete file #{file}" | |
UI. error("Could not delete file #{file}.") |
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.
Good idea! Done here: cc10f9d
`editorial_branch` should already be a `String` Co-authored-by: Gio Lodi <gio.lodi@automattic.com>
Generated by 🚫 Danger |
This PR builds on top of #19149 and configures Rubocop in the project, fixing most of the reported offences.
Some of the offences could be a bit riskier to quickly fix and didn't seem very critical, so I generated a
.rubocop_todo.yml
to silence them for now.