- 'test/models/trace_test.rb'
- 'test/models/tracetag_test.rb'
-# Offense count: 6
-# Configuration parameters: AllowModifier.
-Style/SoleNestedConditional:
- Exclude:
- - 'app/controllers/user_blocks_controller.rb'
- - 'app/models/old_way.rb'
- - 'app/validators/characters_validator.rb'
- - 'app/validators/whitespace_validator.rb'
- - 'lib/classic_pagination/pagination.rb'
-
# Offense count: 28
# Cop supports --auto-correct.
Style/StringConcatenation:
##
# revokes the block, setting the end_time to now
def revoke
- if params[:confirm]
- if @user_block.revoke! current_user
- flash[:notice] = t ".flash"
- redirect_to(@user_block)
- end
+ if params[:confirm] && @user_block.revoke!(current_user)
+ flash[:notice] = t ".flash"
+ redirect_to(@user_block)
end
end
curnode = Node.find(n)
id = n
reuse = curnode.visible
- if oldnode.lat != curnode.lat || oldnode.lon != curnode.lon || oldnode.tags != curnode.tags
- # node has changed: if it's in other ways, give it a new id
- if curnode.ways - [way_id]
- id = -1
- reuse = false
- end
+ # if node has changed and it's in other ways, give it a new id
+ if !curnode.ways.all?(way_id) && (oldnode.lat != curnode.lat || oldnode.lon != curnode.lon || oldnode.tags != curnode.tags)
+ id = -1
+ reuse = false
end
points << [oldnode.lon, oldnode.lat, id, curnode.version, oldnode.tags_as_hash, reuse]
end
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || I18n.t("validations.invalid_characters")) if /[#{INVALID_CHARS}]/.match?(value)
-
- if options[:url_safe]
- record.errors[attribute] << (options[:message] || I18n.t("validations.url_characters", :characters => INVALID_URL_CHARS)) if /[#{INVALID_URL_CHARS}]/.match?(value)
- end
+ record.errors[attribute] << (options[:message] || I18n.t("validations.url_characters", :characters => INVALID_URL_CHARS)) if options[:url_safe] && /[#{INVALID_URL_CHARS}]/.match?(value)
end
end
class WhitespaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- unless options.fetch(:leading, true)
- record.errors[attribute] << (options[:message] || I18n.t("validations.leading_whitespace")) if /\A\s/.match?(value)
- end
-
- unless options.fetch(:trailing, true)
- record.errors[attribute] << (options[:message] || I18n.t("validations.trailing_whitespace")) if /\s\z/.match?(value)
- end
+ record.errors[attribute] << (options[:message] || I18n.t("validations.leading_whitespace")) if !options.fetch(:leading, true) && /\A\s/.match?(value)
+ record.errors[attribute] << (options[:message] || I18n.t("validations.trailing_whitespace")) if !options.fetch(:trailing, true) && /\s\z/.match?(value)
end
end
# object, its +number+ attribute is used as the value; if the page does
# not belong to this Paginator, an ArgumentError is raised.
def current_page=(page)
- if page.is_a? Page
- raise ArgumentError, "Page/Paginator mismatch" unless
- page.paginator == self
- end
+ raise ArgumentError, "Page/Paginator mismatch" if page.is_a?(Page) && page.paginator != self
+
page = page.to_i
@current_page_number = has_page_number?(page) ? page : 1
end