- 'app/models/user.rb'
- 'lib/classic_pagination/pagination.rb'
-# Offense count: 5
-# Cop supports --auto-correct.
-Performance/RegexpMatch:
- Exclude:
- - 'app/helpers/browse_tags_helper.rb'
- - 'app/validators/characters_validator.rb'
- - 'app/validators/whitespace_validator.rb'
-
# Offense count: 5
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql, postgresql
Style/FrozenStringLiteralComment:
Enabled: false
-# Offense count: 2
-# Cop supports --auto-correct.
-Style/IfUnlessModifier:
- Exclude:
- - 'app/controllers/api/ways_controller.rb'
-
# Offense count: 78
# Cop supports --auto-correct.
# Configuration parameters: Strict.
way = Way.find(params[:id])
new_way = Way.from_xml(request.raw_post)
- unless new_way && new_way.id == way.id
- raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})"
- end
+ raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})" unless new_way && new_way.id == way.id
way.update_from(new_way, current_user)
render :plain => way.version.to_s
end
def index
- unless params["ways"]
- raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]"
- end
+ raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]" unless params["ways"]
ids = params["ways"].split(",").collect(&:to_i)
def wikipedia_link(key, value)
# Some k/v's are wikipedia=http://en.wikipedia.org/wiki/Full%20URL
- return nil if value =~ %r{^https?://}
+ return nil if %r{^https?://}.match?(value)
if key == "wikipedia"
# This regex should match Wikipedia language codes, everything
INVALID_URL_CHARS = "/;.,?%#".freeze
def validate_each(record, attribute, value)
- record.errors[attribute] << (options[:message] || I18n.t("validations.invalid_characters")) if value =~ /[#{INVALID_CHARS}]/
+ 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 value =~ /[#{INVALID_URL_CHARS}]/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.url_characters", :characters => INVALID_URL_CHARS)) if /[#{INVALID_URL_CHARS}]/.match?(value)
end
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 value =~ /\A\s/
+ 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 value =~ /\s\z/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.trailing_whitespace")) if /\s\z/.match?(value)
end
end
end