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

Refactor/abc condition #450

Merged
merged 6 commits into from
Dec 6, 2019
Merged

Refactor/abc condition #450

merged 6 commits into from
Dec 6, 2019

Conversation

luke-hill
Copy link
Contributor

Summary

Fix up some rubocop todo's

Details

Refactor some complex methods. Use better names where appropriate

Motivation and Context

Fixes up todo file in rubocop_todo.yml

How Has This Been Tested?

CI

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@luke-hill luke-hill requested a review from mvz December 6, 2019 12:31
Copy link
Contributor

@mvz mvz left a comment

Choose a reason for hiding this comment

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

Good to see this getting cleaned up 👍. Just a few small nits.

delete_environment_variable 'BUNDLE_BIN_PATH'
delete_environment_variable 'BUNDLE_GEMFILE'
command_result = run_rails_new_command(options)
validate_rails_new_success(command_result)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method will be clearer if run_rails_new_command and validate_rails_new_success are merged. I think it also makes sense to have validation be part of the running.

env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
env['action_dispatch.show_exceptions'] = !env['action_dispatch.show_detailed_exceptions']
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

emulated_method&.casecmp(method)&.zero?
end

def add_hidden_input(document, js_form)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about naming this add_hidden_method_input?


js_form
end

def same?(emulated_method, method)
emulated_method&.casecmp(method)&.zero?
Copy link
Contributor

Choose a reason for hiding this comment

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

This line tells me that emulated_method is never nil, so the safe calls can be removed.

end

def csrf_and_non_get?(emulated_method)
csrf? && !emulated_method.casecmp('get').zero?
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, you can use !same?(emulated_method, 'get').

Copy link
Contributor

@mvz mvz left a comment

Choose a reason for hiding this comment

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

:shipit:

@luke-hill luke-hill merged commit 890dae7 into master Dec 6, 2019
@luke-hill luke-hill deleted the refactor/abc_condition branch December 6, 2019 15:52
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.

2 participants