Conversation
cd7fda2
to
762bc5b
Compare
customer: @customer, | ||
store_in_vault: @store_in_vault | ||
).create.id | ||
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.
Rubocop, you naughty machine.
Vince, thank you for doing this. I love it. |
oh, and I'm totally down with |
Vince, I think we should get this merged. What say you? |
@@ -38,7 +38,7 @@ def liquid_data(supplemental_data = {}) | |||
end | |||
|
|||
def recurring? | |||
read_attribute(:recurring_default) > 0 | |||
read_attribute(:recurring_default).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.
was this rubocop?
@@ -26,7 +26,7 @@ class Link < ActiveRecord::Base | |||
private | |||
|
|||
def url_has_protocol | |||
unless %r{^(https?:)?\/\/}i =~ url | |||
unless %r{^(https?:)?\/\/}i.match?(url) |
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.
was this rubocop?
@@ -33,7 +33,7 @@ def dup | |||
clone = super | |||
clone.save! | |||
|
|||
clone.form.form_elements = form.form_elements.map(&:dup) if clone.form | |||
clone.form&.form_elements = form.form_elements.map(&:dup) |
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.
these are not equivalent expressions. If clone.form
is not present this raises an Undefined method form elements for nil
exception. We should keep the guard expression.
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 catch
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.
Does it though? I'll write a test case to double check, but this seems to work:
irb(main):014:0> house = OpenStruct.new(room: OpenStruct.new(people: 0))
=> #<OpenStruct room=#<OpenStruct people=0>>
irb(main):019:0> house.room.people = 10
=> 10
irb(main):021:0> house.cupboards&.people = 10
=> nil
irb(main):020:0> house.cupboards.people = 10
NoMethodError: undefined method `people=' for nil:NilClass
from (irb):20
from /Users/vincent/.rbenv/versions/2.3.3/bin/irb:11:in `<main>'
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.
That's interesting! I didn't know you could use the safe operator on the left side of an assignment. This means that it's clearly doing more than the old ActiveSupport try
.
@@ -17,9 +17,9 @@ class Share::Email < ActiveRecord::Base | |||
include Share::Variant | |||
|
|||
validates :subject, :body, presence: true | |||
validate :has_link | |||
validate :has_link, unless: -> { body.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.
is it safe to remove this? This change makes the validation run even when the body is 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.
@rodrei it's an addition.
@@ -17,9 +17,9 @@ class Share::Twitter < ActiveRecord::Base | |||
include Share::Variant | |||
|
|||
validates :description, presence: true | |||
validate :has_link | |||
validate :has_link, unless: -> { description.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.
same as above
page: @page, | ||
url: @page_url | ||
) | ||
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.
I hate this indentation style 👎 . I vote for us to remove this rubocop check and align it like this:
variant = if condition?
do.something
else
do.something_else
end
app/services/search/page_searcher.rb
Outdated
@@ -7,7 +7,7 @@ def initialize(params) | |||
|
|||
def search | |||
[*@queries].each do |search_type, query| | |||
if !validate_query(query) | |||
if query.blank? |
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.
🥇
@@ -6,7 +6,7 @@ module Helper | |||
def check_petition_name_is_available(name) | |||
resp = ActionKit::Client.get('petitionpage', params: { _limit: 1, name: name }) | |||
if resp.code == 200 | |||
JSON.parse(resp.body)['meta']['total_count'] == 0 | |||
(JSON.parse(resp.body)['meta']['total_count']).zero? |
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.
is this rubocop?
Other than my comments, this looks awesome! Great job @eyko! |
@eyko sending you a friendly ping. |
This seemed to work fine on staging. Let's try and get it merged before Wednesday - does that sound feasible? |
Because why not.
Rails 4.2.8 also brings ruby 2.4 support so we can either keep 2.3.3 or update to 2.4.0. In this PR I've taken the 2.4.0 route (was that predictable?) but I'll describe both options:
Staying with ruby 2.3.3
Other than updating the rails gem, I don't think any other changes are necessary, but since we're updating the Gemfile / Gemfile.lock tandem, I'd also take the opportunity to change the
github: '...'
gems to usegit: 'https://...'
so we can get rid of the annoying bundler warnings - or am I the only one that's bothered?With ruby 2.4.0
With 2.4 a few changes are necessary:
Fixnum
/Bignum
occurrences toInteger
: a5f2189 (see https://bugs.ruby-lang.org/issues/12005)webmock
: 25fd407#diff-e79a60dc6b85309ae70a6ea8261eaf95L519.ruby-version
). This is actually annoying because new rubocop versions introduce new cops like Bundler/OrderedGems which are a bit silly (and we're going to turn off right???). I've autocorrected some rubocop issues 3794b21 and I'm disabling the rest unless they make sense.