From: Tom Hughes Date: Tue, 18 Aug 2015 19:57:14 +0000 (+0100) Subject: Fix new rubocopy warnings X-Git-Tag: live~4633 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/c9d35839befe92d916425baa4daec7dd77ade929?ds=sidebyside Fix new rubocopy warnings --- diff --git a/.rubocop.yml b/.rubocop.yml index 19403fed5..213eb27aa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,9 @@ AllCops: Style/BracesAroundHashParameters: EnforcedStyle: context_dependent +Style/ExtraSpacing: + AllowForAlignment: true + Style/FileName: Exclude: - 'script/deliver-message' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e1b70a2d8..71d949dae 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,5 +1,6 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2015-06-08 15:55:30 +0100 using RuboCop version 0.32.0. +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2015-08-18 20:27:49 +0100 using RuboCop version 0.33.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -7,26 +8,54 @@ # Offense count: 34 Lint/AmbiguousOperator: - Enabled: false + Exclude: + - 'test/controllers/amf_controller_test.rb' + - 'test/controllers/changeset_controller_test.rb' + - 'test/lib/bounding_box_test.rb' + - 'test/lib/country_test.rb' # Offense count: 115 Lint/AmbiguousRegexpLiteral: Enabled: false -# Offense count: 30 +# Offense count: 29 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: - Enabled: false + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/geocoder_controller.rb' + - 'app/controllers/notes_controller.rb' + - 'app/controllers/trace_controller.rb' + - 'app/controllers/user_controller.rb' + - 'app/controllers/user_preference_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/browse_helper.rb' + - 'app/models/client_application.rb' + - 'app/models/notifier.rb' + - 'lib/nominatim.rb' + - 'lib/osm.rb' + - 'script/deliver-message' + +# Offense count: 3 +Lint/FormatParameterMismatch: + Exclude: + - 'app/controllers/swf_controller.rb' # Offense count: 5 Lint/HandleExceptions: - Enabled: false + Exclude: + - 'app/controllers/amf_controller.rb' + - 'app/controllers/user_controller.rb' + - 'config/initializers/session.rb' # Offense count: 8 Lint/ParenthesesAsGroupedExpression: - Enabled: false + Exclude: + - 'test/controllers/amf_controller_test.rb' + - 'test/lib/bounding_box_test.rb' + - 'test/models/user_preference_test.rb' -# Offense count: 669 +# Offense count: 671 Metrics/AbcSize: Max: 277 @@ -43,12 +72,12 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 20 -# Offense count: 2537 +# Offense count: 2535 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: Max: 694 -# Offense count: 623 +# Offense count: 628 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 179 @@ -70,34 +99,65 @@ Metrics/PerceivedComplexity: # Offense count: 2 # Configuration parameters: Include. Rails/HasAndBelongsToMany: - Enabled: false + Exclude: + - 'app/models/changeset.rb' + - 'app/models/user.rb' -# Offense count: 67 +# Offense count: 66 # Configuration parameters: EnforcedStyle, SupportedStyles. Rails/TimeZone: Enabled: false # Offense count: 5 Style/AccessorMethodName: - Enabled: false + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/helpers/title_helper.rb' + - 'app/models/old_way.rb' + - 'lib/osm.rb' + - 'lib/potlatch.rb' # Offense count: 1 Style/AsciiComments: - Enabled: false + Exclude: + - 'test/models/message_test.rb' -# Offense count: 308 +# Offense count: 310 Style/Documentation: Enabled: false # Offense count: 38 # Configuration parameters: MinBodyLength. Style/GuardClause: - Enabled: false + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/diary_entry_controller.rb' + - 'app/controllers/message_controller.rb' + - 'app/controllers/notes_controller.rb' + - 'app/controllers/site_controller.rb' + - 'app/controllers/user_blocks_controller.rb' + - 'app/controllers/user_controller.rb' + - 'app/controllers/user_roles_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/models/changeset.rb' + - 'app/models/user.rb' + - 'lib/diff_reader.rb' + - 'lib/object_metadata.rb' # Offense count: 60 # Cop supports --auto-correct. Style/LineEndConcatenation: - Enabled: false + Exclude: + - 'db/migrate/008_remove_segments.rb' + - 'db/migrate/020_populate_node_tags_and_remove.rb' + - 'db/migrate/023_add_changesets.rb' + - 'lib/bounding_box.rb' + - 'lib/diff_reader.rb' + - 'lib/osm.rb' + - 'test/controllers/changeset_controller_test.rb' + - 'test/controllers/node_controller_test.rb' + - 'test/controllers/relation_controller_test.rb' + - 'test/controllers/way_controller_test.rb' # Offense count: 69 # Cop supports --auto-correct. @@ -107,12 +167,25 @@ Style/NumericLiterals: # Offense count: 42 # Cop supports --auto-correct. Style/PerlBackrefs: - Enabled: false + Exclude: + - 'app/controllers/amf_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/helpers/browse_helper.rb' + - 'config/initializers/paperclip.rb' + - 'lib/id.rb' + - 'lib/potlatch.rb' + - 'test/lib/i18n_test.rb' # Offense count: 8 # Configuration parameters: NamePrefix, NamePrefixBlacklist. Style/PredicateName: - Enabled: false + Exclude: + - 'app/models/changeset.rb' + - 'app/models/old_node.rb' + - 'app/models/old_relation.rb' + - 'app/models/old_way.rb' + - 'app/models/user.rb' + - 'lib/classic_pagination/pagination.rb' # Offense count: 97 # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -121,16 +194,11 @@ Style/RaiseArgs: # Offense count: 2 Style/RescueModifier: - Enabled: false + Exclude: + - 'app/helpers/browse_helper.rb' # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/StringLiteralsInInterpolation: Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. -Style/TrivialAccessors: - Enabled: false diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index fb50b6aad..f6ae7f231 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -98,7 +98,7 @@ class AmfController < ApplicationController result = startchangeset(*args) end - err = true if result[0] == -3 # If a conflict is detected, don't execute any more writes + err = true if result[0] == -3 # If a conflict is detected, don't execute any more writes end result @@ -527,7 +527,7 @@ class AmfController < ApplicationController # 3. version. def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible) #:doc: - amf_handle_error("'putrelation' #{relid}", "relation", relid) do + amf_handle_error("'putrelation' #{relid}", "relation", relid) do user = getuser(usertoken) return -1, "You are not logged in, so the relation could not be saved." unless user @@ -645,7 +645,7 @@ class AmfController < ApplicationController return -2, "Server error - node with id 0 found in way #{originalway}." if id == 0 return -2, "Server error - node with latitude -90 found in way #{originalway}." if lat == 90 - id = renumberednodes[id] if renumberednodes[id] + id = renumberednodes[id] if renumberednodes[id] node = Node.new node.changeset_id = changeset_id diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 618f08a1f..3470db86c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -448,11 +448,11 @@ class ApplicationController < ActionController::Base # extract authorisation credentials from headers, returns user = nil if none def get_auth_data - if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it + if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it authdata = request.env["X-HTTP_AUTHORIZATION"].to_s.split - elsif request.env.key? "REDIRECT_X_HTTP_AUTHORIZATION" # mod_fcgi + elsif request.env.key? "REDIRECT_X_HTTP_AUTHORIZATION" # mod_fcgi authdata = request.env["REDIRECT_X_HTTP_AUTHORIZATION"].to_s.split - elsif request.env.key? "HTTP_AUTHORIZATION" # regular location + elsif request.env.key? "HTTP_AUTHORIZATION" # regular location authdata = request.env["HTTP_AUTHORIZATION"].to_s.split end # only basic authentication supported diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 31004e8ee..2ce024c76 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -456,7 +456,7 @@ class ChangesetController < ApplicationController # restrict changesets to those enclosed by a bounding box # we need to return both the changesets and the bounding box def conditions_bbox(changesets, bbox) - if bbox + if bbox bbox.check_boundaries bbox = bbox.to_scaled return changesets.where("min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?", diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 20e4d7d1d..b6fb455ee 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -98,7 +98,7 @@ class GeocoderController < ApplicationController unless response.match(/Error/) dataline = response.split(/\n/)[1] data = dataline.split(/,/) # easting,northing,postcode,lat,long - postcode = data[2].gsub(/'/, "") + postcode = data[2].delete("'") zoom = POSTCODE_ZOOM - postcode.count("#") @results.push(:lat => data[3], :lon => data[4], :zoom => zoom, :name => postcode) @@ -174,7 +174,7 @@ class GeocoderController < ApplicationController if type.empty? prefix_name = "" else - prefix_name = t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.gsub("_", " ").capitalize + prefix_name = t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.tr("_", " ").capitalize end if klass == "boundary" && type == "administrative" rank = (place.attributes["place_rank"].to_i + 1) / 2 diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 2973a26c2..59dd025e8 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -278,8 +278,8 @@ class NotesController < ApplicationController def mine if params[:display_name] if @this_user = User.active.find_by_display_name(params[:display_name]) - @title = t "note.mine.title", :user => @this_user.display_name - @heading = t "note.mine.heading", :user => @this_user.display_name + @title = t "note.mine.title", :user => @this_user.display_name + @heading = t "note.mine.heading", :user => @this_user.display_name @description = t "note.mine.subheading", :user => render_to_string(:partial => "user", :object => @this_user) @page = (params[:page] || 1).to_i @page_size = 10 diff --git a/app/controllers/swf_controller.rb b/app/controllers/swf_controller.rb index a683e2177..ceaf7e4c0 100644 --- a/app/controllers/swf_controller.rb +++ b/app/controllers/swf_controller.rb @@ -31,7 +31,7 @@ class SwfController < ApplicationController bounds_top = 240 * 20 m = "" - m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background + m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background absx = 0 absy = 0 xl = yb = 9999999 @@ -47,7 +47,7 @@ class SwfController < ApplicationController user = User.authenticate(:token => params[:token]) sql = "SELECT gps_points.latitude*0.0000001 AS lat,gps_points.longitude*0.0000001 AS lon,gpx_files.id AS fileid," + " EXTRACT(EPOCH FROM gps_points.timestamp) AS ts, gps_points.trackid AS trackid " + " FROM gpx_files,gps_points " + "WHERE gpx_files.id=gpx_id " + " AND gpx_files.user_id=#{user.id} " + " AND " + OSM.sql_for_area(bbox, "gps_points.") + " AND (gps_points.timestamp IS NOT NULL) " + "ORDER BY fileid DESC,ts " + "LIMIT 10000 OFFSET #{start}" else - sql = "SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,gpx_id AS fileid," + " EXTRACT(EPOCH FROM timestamp) AS ts, gps_points.trackid AS trackid " + " FROM gps_points " + "WHERE " + OSM.sql_for_area(bbox, "gps_points.") + " AND (gps_points.timestamp IS NOT NULL) " + "ORDER BY fileid DESC,ts " + "LIMIT 10000 OFFSET #{start}" + sql = "SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,gpx_id AS fileid," + " EXTRACT(EPOCH FROM timestamp) AS ts, gps_points.trackid AS trackid " + " FROM gps_points " + "WHERE " + OSM.sql_for_area(bbox, "gps_points.") + " AND (gps_points.timestamp IS NOT NULL) " + "ORDER BY fileid DESC,ts " + "LIMIT 10000 OFFSET #{start}" end gpslist = ActiveRecord::Base.connection.select_all sql @@ -104,11 +104,11 @@ class SwfController < ApplicationController # Line-drawing def start_shape - s = 0.chr # No fill styles - s += 2.chr # Two line styles - s += pack_u16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF - s += pack_u16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF - s += 34.chr # 2 fill, 2 line index bits + s = 0.chr # No fill styles + s += 2.chr # Two line styles + s += pack_u16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF + s += pack_u16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF + s += 34.chr # 2 fill, 2 line index bits s end @@ -117,10 +117,10 @@ class SwfController < ApplicationController end def start_and_move(x, y, col) - d = "001001" # Line style change, moveTo + d = "001001" # Line style change, moveTo l = [length_sb(x), length_sb(y)].max d += format("%05b%0*b%0*b", l, l, x, l, y) - d += col # Select line style + d += col # Select line style d end diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index cfacad6a4..bda0a7942 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -235,7 +235,7 @@ class TraceController < ApplicationController def icon trace = Trace.find(params[:id]) - if trace.visible? && trace.inserted? + if trace.visible? && trace.inserted? if trace.public? || (@user && @user == trace.user) expires_in 7.days, :private => !trace.public?, :public => trace.public? send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline") diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 0c2514927..0f77c87a0 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -625,7 +625,7 @@ class UserController < ApplicationController def failed_login(message) flash[:error] = message - redirect_to :action => "login", :referer => session[:referer] + redirect_to :action => "login", :referer => session[:referer] session.delete(:remember_me) session.delete(:referer) diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 5d0a18fd9..3723186b8 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -122,7 +122,7 @@ module BrowseHelper if value =~ /^([a-z-]{2,12}):(.+)$/i # Value is : so split it up # Note that value is always left as-is, see: https://trac.openstreetmap.org/ticket/4315 - lang = $1 + lang = $1 else # Value is <title> so default to English Wikipedia lang = "en" @@ -140,7 +140,7 @@ module BrowseHelper # Must break it up to correctly build the url value = $1 section = "#" + $2 - encoded_section = "#" + URI.encode($2.gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).gsub("%", ".") + encoded_section = "#" + URI.encode($2.gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).tr("%", ".") else section = "" encoded_section = "" diff --git a/app/models/notifier.rb b/app/models/notifier.rb index ff3349e28..018226566 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -108,7 +108,7 @@ class Notifier < ActionMailer::Base :title => "Re: #{comment.diary_entry.title}") mail :from => from_address(comment.user.display_name, "c", comment.id, comment.digest), - :to => comment.diary_entry.user.email, + :to => comment.diary_entry.user.email, :subject => I18n.t("notifier.diary_comment_notification.subject", :user => comment.user.display_name) end end diff --git a/app/models/user.rb b/app/models/user.rb index a95724c96..0053333e2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,7 +12,7 @@ class User < ActiveRecord::Base has_many :tokens, :class_name => "UserToken" has_many :preferences, :class_name => "UserPreference" has_many :changesets, -> { order(:created_at => :desc) } - has_many :changeset_comments, :foreign_key => :author_id + has_many :changeset_comments, :foreign_key => :author_id has_and_belongs_to_many :changeset_subscriptions, :class_name => "Changeset", :join_table => "changesets_subscribers", :foreign_key => "subscriber_id" has_many :note_comments, :foreign_key => :author_id has_many :notes, :through => :note_comments diff --git a/db/migrate/020_populate_node_tags_and_remove.rb b/db/migrate/020_populate_node_tags_and_remove.rb index d12ede317..63b7ea21a 100644 --- a/db/migrate/020_populate_node_tags_and_remove.rb +++ b/db/migrate/020_populate_node_tags_and_remove.rb @@ -31,8 +31,8 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration create_table :current_node_tags, :id => false do |t| t.column :id, :bigint, :null => false - t.column :k, :string, :default => "", :null => false - t.column :v, :string, :default => "", :null => false + t.column :k, :string, :default => "", :null => false + t.column :v, :string, :default => "", :null => false end create_table :node_tags, :id => false do |t| diff --git a/db/migrate/20140507110937_create_changeset_comments.rb b/db/migrate/20140507110937_create_changeset_comments.rb index 26c257cbc..0b36fa228 100644 --- a/db/migrate/20140507110937_create_changeset_comments.rb +++ b/db/migrate/20140507110937_create_changeset_comments.rb @@ -4,7 +4,7 @@ class CreateChangesetComments < ActiveRecord::Migration def change create_table :changeset_comments do |t| t.column :changeset_id, :bigint, :null => false - t.column :author_id, :bigint, :null => false + t.column :author_id, :bigint, :null => false t.text :body, :null => false t.timestamp :created_at, :null => false t.boolean :visible, :null => false diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb index 459143076..6ffe3806a 100644 --- a/lib/diff_reader.rb +++ b/lib/diff_reader.rb @@ -57,7 +57,7 @@ class DiffReader # care of that for us. if @reader.node_type == 1 # element name = @reader.name - attributes = {} + attributes = {} if @reader.has_attributes? while @reader.move_to_next_attribute == 1 diff --git a/lib/osm.rb b/lib/osm.rb index 7556e631b..502bc307a 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -498,7 +498,7 @@ module OSM root["generator"] = GENERATOR root["copyright"] = COPYRIGHT_OWNER root["attribution"] = ATTRIBUTION_URL - root["license"] = LICENSE_URL + root["license"] = LICENSE_URL doc.root = root doc end diff --git a/lib/potlatch.rb b/lib/potlatch.rb index 27ee0253b..a077d4c4d 100644 --- a/lib/potlatch.rb +++ b/lib/potlatch.rb @@ -24,7 +24,7 @@ module Potlatch # Return eight-byte double-precision float def self.getdouble(s) - a = s.read(8).unpack("G") # G big-endian, E little-endian + a = s.read(8).unpack("G") # G big-endian, E little-endian a[0] end @@ -42,23 +42,23 @@ module Potlatch break if key == "" arr[key] = getvalue(s) end - s.getbyte # skip the 9 'end of object' value + s.getbyte # skip the 9 'end of object' value arr end # Parse and get value def self.getvalue(s) case s.getbyte - when 0 then return getdouble(s) # number - when 1 then return s.getbyte # boolean - when 2 then return getstring(s) # string - when 3 then return getobject(s) # object/hash - when 5 then return nil # null - when 6 then return nil # undefined - when 8 then s.read(4) # mixedArray - return getobject(s) # | - when 10 then return getarray(s) # array - else return nil # error + when 0 then return getdouble(s) # number + when 1 then return s.getbyte # boolean + when 2 then return getstring(s) # string + when 3 then return getobject(s) # object/hash + when 5 then return nil # null + when 6 then return nil # undefined + when 8 then s.read(4) # mixedArray + return getobject(s) # | + when 10 then return getarray(s) # array + else return nil # error end end diff --git a/lib/short_link.rb b/lib/short_link.rb index ddf37b67a..43d64041e 100644 --- a/lib/short_link.rb +++ b/lib/short_link.rb @@ -22,7 +22,7 @@ module ShortLink # keep support for old shortlinks which use the @ character, now # replaced by the ~ character because twitter is horribly broken # and we can't have that. - str.gsub!("@", "~") + str.tr!("@", "~") str.each_char do |c| t = ARRAY.index c diff --git a/lib/tasks/add_version_to_nodes.rake b/lib/tasks/add_version_to_nodes.rake index cdcf13a3e..057330418 100644 --- a/lib/tasks/add_version_to_nodes.rake +++ b/lib/tasks/add_version_to_nodes.rake @@ -1,6 +1,6 @@ namespace "db" do desc "Adds a version number to the nodes table" - task :node_version do + task :node_version do require File.dirname(__FILE__) + "/../../config/environment" increment = 1000 diff --git a/script/rails b/script/rails index e667e55e3..9a5a81dcf 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path("../../config/application", __FILE__) -require File.expand_path("../../config/boot", __FILE__) +APP_PATH = File.expand_path("../../config/application", __FILE__) +require File.expand_path("../../config/boot", __FILE__) require "rails/commands" diff --git a/test/controllers/amf_controller_test.rb b/test/controllers/amf_controller_test.rb index 13f01530d..d388114dd 100644 --- a/test/controllers/amf_controller_test.rb +++ b/test/controllers/amf_controller_test.rb @@ -1358,24 +1358,24 @@ class AmfControllerTest < ActionController::TestCase def amf_parse_response req = StringIO.new(@response.body) - req.read(2) # version + req.read(2) # version # parse through any headers - headers = AMF.getint(req) # Read number of headers - headers.times do # Read each header - AMF.getstring(req) # | - req.getc # | skip boolean - AMF.getvalue(req) # | + headers = AMF.getint(req) # Read number of headers + headers.times do # Read each header + AMF.getstring(req) # | + req.getc # | skip boolean + AMF.getvalue(req) # | end # parse through responses results = {} - bodies = AMF.getint(req) # Read number of bodies - bodies.times do # Read each body - message = AMF.getstring(req) # | get message name - AMF.getstring(req) # | get index in response sequence - AMF.getlong(req) # | get total size in bytes - args = AMF.getvalue(req) # | get response (probably an array) + bodies = AMF.getint(req) # Read number of bodies + bodies.times do # Read each body + message = AMF.getstring(req) # | get message name + AMF.getstring(req) # | get index in response sequence + AMF.getlong(req) # | get total size in bytes + args = AMF.getvalue(req) # | get response (probably an array) results[message] = args end @amf_result = results diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index d10e5277e..116af7362 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -385,7 +385,7 @@ class ApiControllerTest < ActionController::TestCase end def test_permissions_oauth - @request.env["oauth.token"] = AccessToken.new do |token| + @request.env["oauth.token"] = AccessToken.new do |token| # Just to test a few token.allow_read_prefs = true token.allow_write_api = true diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index a1667a533..582d1ee5c 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -1477,12 +1477,12 @@ EOF # NOTE: the include method doesn't over-expand, like inserting # a real method does. this is because we expect the client to # know what it is doing! - check_after_include(changeset_id, 1, 1, [1, 1, 1, 1]) - check_after_include(changeset_id, 3, 3, [1, 1, 3, 3]) - check_after_include(changeset_id, 4, 2, [1, 1, 4, 3]) - check_after_include(changeset_id, 2, 2, [1, 1, 4, 3]) - check_after_include(changeset_id, -1, -1, [-1, -1, 4, 3]) - check_after_include(changeset_id, -2, 5, [-2, -1, 4, 5]) + check_after_include(changeset_id, 1, 1, [1, 1, 1, 1]) + check_after_include(changeset_id, 3, 3, [1, 1, 3, 3]) + check_after_include(changeset_id, 4, 2, [1, 1, 4, 3]) + check_after_include(changeset_id, 2, 2, [1, 1, 4, 3]) + check_after_include(changeset_id, -1, -1, [-1, -1, 4, 3]) + check_after_include(changeset_id, -2, 5, [-2, -1, 4, 5]) end ## diff --git a/test/controllers/geocoder_controller_test.rb b/test/controllers/geocoder_controller_test.rb index bc75a9bfb..7899bd982 100644 --- a/test/controllers/geocoder_controller_test.rb +++ b/test/controllers/geocoder_controller_test.rb @@ -446,7 +446,7 @@ class GeocoderControllerTest < ActionController::TestCase xhr :get, :search_osm_nominatim_reverse, :lat => 51.7632, :lon => -0.0076, :zoom => 17 results_check :name => "Dinant Link Road, Broxbourne, Hertfordshire, East of England, England, EN11 8HX, United Kingdom", :lat => 51.7634883, :lon => -0.0088373, - :type => "way", :id => 3489841, :zoom => 17 + :type => "way", :id => 3489841, :zoom => 17 end end diff --git a/test/controllers/oauth_clients_controller_test.rb b/test/controllers/oauth_clients_controller_test.rb index 1c3c14f86..6bafa62cc 100644 --- a/test/controllers/oauth_clients_controller_test.rb +++ b/test/controllers/oauth_clients_controller_test.rb @@ -84,7 +84,7 @@ class OauthClientsControllerTest < ActionController::TestCase :client_application => { :name => "Test Application" } - }, { :user => user } + }, { :user => user } end assert_response :success assert_template "new" @@ -96,7 +96,7 @@ class OauthClientsControllerTest < ActionController::TestCase :name => "Test Application", :url => "http://test.example.com/" } - }, { :user => user } + }, { :user => user } end assert_response :redirect assert_redirected_to oauth_client_path(:id => ClientApplication.find_by_name("Test Application").id) @@ -163,7 +163,7 @@ class OauthClientsControllerTest < ActionController::TestCase :name => "New Name", :url => nil } - }, { :user => user } + }, { :user => user } assert_response :success assert_template "edit" @@ -174,7 +174,7 @@ class OauthClientsControllerTest < ActionController::TestCase :name => "New Name", :url => "http://new.example.com/url" } - }, { :user => user } + }, { :user => user } assert_response :redirect assert_redirected_to oauth_client_path(:id => client.id) end diff --git a/test/controllers/old_node_controller_test.rb b/test/controllers/old_node_controller_test.rb index 067f6599c..f2658b123 100644 --- a/test/controllers/old_node_controller_test.rb +++ b/test/controllers/old_node_controller_test.rb @@ -147,7 +147,7 @@ class OldNodeControllerTest < ActionController::TestCase check_not_found_id_version(70000, 312344) check_not_found_id_version(-1, -13) check_not_found_id_version(nodes(:visible_node).id, 24354) - check_not_found_id_version(24356, nodes(:visible_node).version) + check_not_found_id_version(24356, nodes(:visible_node).version) end def check_not_found_id_version(id, version) diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb index 6c66358a0..7935b4b2a 100644 --- a/test/controllers/site_controller_test.rb +++ b/test/controllers/site_controller_test.rb @@ -292,7 +292,7 @@ class SiteControllerTest < ActionController::TestCase # Test editing a specific note def test_edit_with_note user = users(:public_user) - note = notes(:open_note) + note = notes(:open_note) get :edit, { :note => note.id }, { :user => user.id } assert_response :success diff --git a/test/integration/locale_test.rb b/test/integration/locale_test.rb index 94007cd3c..c8c310e11 100644 --- a/test/integration/locale_test.rb +++ b/test/integration/locale_test.rb @@ -20,7 +20,7 @@ class LocaleTest < ActionDispatch::IntegrationTest assert_equal [], User.find(user.id).languages assert_select "html[lang=?]", "en" - get "/diary/new", {}, { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } + get "/diary/new", {}, { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } assert_equal %w(fr en), User.find(user.id).languages assert_select "html[lang=?]", "fr" end diff --git a/test/lib/bounding_box_test.rb b/test/lib/bounding_box_test.rb index 834d217cb..e704d89b8 100644 --- a/test/lib/bounding_box_test.rb +++ b/test/lib/bounding_box_test.rb @@ -26,8 +26,8 @@ class BoundingBoxTest < ActiveSupport::TestCase @bad_lat_mixed_bbox = %w(0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33) @bad_lon_mixed_bbox = %w(80,-0.1,70,0.1 54.34,0.24,54.33,0.25) @bad_limit_bbox = %w(-180.1,-90,180,90 -180,-90.1,180,90 -180,-90,180.1,90 -180,-90,180,90.1) - @good_bbox = %w(-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0 -0.1,%20-0.1,%200.1,%200.1 - -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1) + @good_bbox = %w(-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0 -0.1,%20-0.1,%200.1,%200.1 + -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1) @expand_min_lon_array = %w(2,10,10,10 1,10,10,10 0,10,10,10 -1,10,10,10 -2,10,10,10 -8,10,10,10) @expand_min_lat_array = %w(10,2,10,10 10,1,10,10 10,0,10,10 10,-1,10,10 10,-2,10,10 10,-8,10,10)