Fix some rubocop todos
This commit is contained in:
parent
06952ea2b3
commit
77f9aec772
5 changed files with 7 additions and 25 deletions
|
@ -98,14 +98,6 @@ Naming/PredicateName:
|
|||
- '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
|
||||
|
@ -190,12 +182,6 @@ Style/FormatStringToken:
|
|||
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.
|
||||
|
|
|
@ -43,9 +43,7 @@ module Api
|
|||
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
|
||||
|
@ -90,9 +88,7 @@ module Api
|
|||
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)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ module BrowseTagsHelper
|
|||
|
||||
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
|
||||
|
|
|
@ -3,10 +3,10 @@ class CharactersValidator < ActiveModel::EachValidator
|
|||
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
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue