From: Tom Hughes Date: Fri, 9 Oct 2020 07:26:38 +0000 (+0100) Subject: Fix new rubocop warnings X-Git-Tag: live~2011 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2dc50b4431dbf01c2ad9402a5a6f8772ce0a7cc7?ds=sidebyside Fix new rubocop warnings --- diff --git a/lib/potlatch.rb b/lib/potlatch.rb index 75b81bbc5..4d9fd1c23 100644 --- a/lib/potlatch.rb +++ b/lib/potlatch.rb @@ -180,13 +180,13 @@ module Potlatch # StringIO.open(txt) do |file| File.open(Rails.root.join("config/potlatch/presets.txt")) do |file| file.each_line do |line| - t = line.chomp - if t =~ %r{(\w+)/(\w+)} + case line.chomp + when %r{(\w+)/(\w+)} presettype = Regexp.last_match(1) presetcategory = Regexp.last_match(2) presetmenus[presettype].push(presetcategory) presetnames[presettype][presetcategory] = ["(no preset)"] - elsif t =~ /^([\w\s]+):\s?(.+)$/ + when /^([\w\s]+):\s?(.+)$/ pre = Regexp.last_match(1) kv = Regexp.last_match(2) presetnames[presettype][presetcategory].push(pre) diff --git a/test/controllers/api/changesets_controller_test.rb b/test/controllers/api/changesets_controller_test.rb index 871eac9ed..1f394d126 100644 --- a/test/controllers/api/changesets_controller_test.rb +++ b/test/controllers/api/changesets_controller_test.rb @@ -71,7 +71,7 @@ module Api duration = cs.closed_at - cs.created_at # the difference can either be a rational, or a floating point number # of seconds, depending on the code path taken :-( - if duration.class == Rational + if duration.instance_of?(Rational) assert_equal Rational(1, 24), duration, "initial idle timeout should be an hour (#{cs.created_at} -> #{cs.closed_at})" else # must be number of seconds...