diff --git a/.rubocop.yml b/.rubocop.yml index aeca87e..3c1993e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -136,7 +136,7 @@ Style/Documentation: Enabled: false # This is just silly. Calling the argument `other` in all cases makes no sense. -Style/OpMethod: +Naming/BinaryOperatorParameterName: Enabled: false # There are valid cases, for example debugging Cucumber steps, diff --git a/Gemfile b/Gemfile index ce6c8ec..011559c 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :development do # code style gem "pronto", "0.9.5", require: false gem "pronto-rubocop", "0.9.0", require: false - gem "rubocop", "0.49.1", require: false + gem "rubocop", "0.50.0", require: false # automatic test runs gem "guard-rspec", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 406b1b3..cddabd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,14 +181,14 @@ GEM rspec-mocks (~> 3.6.0) rspec-support (~> 3.6.0) rspec-support (3.6.0) - rubocop (0.49.1) + rubocop (0.50.0) parallel (~> 1.10) parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rainbow (>= 2.2.2, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.8.1) + ruby-progressbar (1.8.3) ruby_dep (1.5.0) rugged (0.26.0) safe_yaml (1.0.4) @@ -252,7 +252,7 @@ DEPENDENCIES rspec-collection_matchers (~> 1.1.2) rspec-json_expectations (~> 2.1) rspec-rails (~> 3.6.0) - rubocop (= 0.49.1) + rubocop (= 0.50.0) simplecov (= 0.15.1) simplecov-rcov (= 0.2.3) spring diff --git a/lib/diaspora_federation/discovery/discovery.rb b/lib/diaspora_federation/discovery/discovery.rb index 8fbfad4..f52c683 100644 --- a/lib/diaspora_federation/discovery/discovery.rb +++ b/lib/diaspora_federation/discovery/discovery.rb @@ -26,7 +26,7 @@ module DiasporaFederation person rescue DiscoveryError raise # simply re-raise DiscoveryError - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass raise DiscoveryError, "Failed discovery for #{diaspora_id}: #{e.class}: #{e.message}" end @@ -48,7 +48,7 @@ module DiasporaFederation response = HttpClient.get(url) raise "Failed to fetch #{url}: #{response.status}" unless response.success? response.body - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass unless http_fallback && url.start_with?("https://") raise DiscoveryError, "Failed to fetch #{url} for #{diaspora_id}: #{e.class}: #{e.message}" end @@ -78,7 +78,7 @@ module DiasporaFederation # This tries the WebFinger URL with https first, then falls back to http if webfinger_http_fallback is enabled. @webfinger = WebFinger.from_json(get(webfinger_url, DiasporaFederation.webfinger_http_fallback)) - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass logger.warn "WebFinger failed, retrying with legacy WebFinger for #{diaspora_id}: #{e.class}: #{e.message}" @webfinger = WebFinger.from_xml(get(legacy_webfinger_url_from_host_meta)) end diff --git a/lib/diaspora_federation/federation/diaspora_url_parser.rb b/lib/diaspora_federation/federation/diaspora_url_parser.rb index dad4b41..a9f622d 100644 --- a/lib/diaspora_federation/federation/diaspora_url_parser.rb +++ b/lib/diaspora_federation/federation/diaspora_url_parser.rb @@ -26,7 +26,7 @@ module DiasporaFederation class_name = Entity.entity_class(type).to_s.rpartition("::").last return if DiasporaFederation.callbacks.trigger(:fetch_related_entity, class_name, guid) Fetcher.fetch_public(author, type, guid) - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass logger.error "Failed to fetch linked entity #{type}:#{guid}: #{e.class}: #{e.message}" end end diff --git a/lib/diaspora_federation/federation/fetcher.rb b/lib/diaspora_federation/federation/fetcher.rb index 76cf530..26b8a26 100644 --- a/lib/diaspora_federation/federation/fetcher.rb +++ b/lib/diaspora_federation/federation/fetcher.rb @@ -16,7 +16,7 @@ module DiasporaFederation magic_env_xml = Nokogiri::XML(response.body).root magic_env = Salmon::MagicEnvelope.unenvelop(magic_env_xml) Receiver::Public.new(magic_env).receive - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass raise NotFetchable, "Failed to fetch #{entity_type}:#{guid} from #{author}: #{e.class}: #{e.message}" end diff --git a/lib/diaspora_federation/federation/receiver.rb b/lib/diaspora_federation/federation/receiver.rb index bfe9436..b88cc9f 100644 --- a/lib/diaspora_federation/federation/receiver.rb +++ b/lib/diaspora_federation/federation/receiver.rb @@ -15,7 +15,7 @@ module DiasporaFederation Salmon::MagicEnvelope.unenvelop(magic_env_xml) end Public.new(magic_env).receive - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass logger.error "failed to receive public message: #{e.class}: #{e.message}" logger.debug "received data:\n#{data}" raise e @@ -36,7 +36,7 @@ module DiasporaFederation Salmon::MagicEnvelope.unenvelop(magic_env_xml) end Private.new(magic_env, recipient_id).receive - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass logger.error "failed to receive private message for #{recipient_id}: #{e.class}: #{e.message}" logger.debug "received data:\n#{data}" raise e diff --git a/lib/diaspora_federation/federation/receiver/abstract_receiver.rb b/lib/diaspora_federation/federation/receiver/abstract_receiver.rb index 30a203e..c5c723c 100644 --- a/lib/diaspora_federation/federation/receiver/abstract_receiver.rb +++ b/lib/diaspora_federation/federation/receiver/abstract_receiver.rb @@ -17,7 +17,7 @@ module DiasporaFederation # Validates and receives the entity def receive validate_and_receive - rescue => e + rescue => e # rubocop:disable Lint/RescueWithoutErrorClass logger.error "failed to receive #{entity}" raise e end diff --git a/lib/diaspora_federation/parsers/base_parser.rb b/lib/diaspora_federation/parsers/base_parser.rb index b277654..50b48b9 100644 --- a/lib/diaspora_federation/parsers/base_parser.rb +++ b/lib/diaspora_federation/parsers/base_parser.rb @@ -29,7 +29,7 @@ module DiasporaFederation when :timestamp begin Time.parse(text).utc - rescue + rescue ArgumentError nil end when :integer diff --git a/lib/diaspora_federation/properties_dsl.rb b/lib/diaspora_federation/properties_dsl.rb index b2c99de..2b4cef8 100644 --- a/lib/diaspora_federation/properties_dsl.rb +++ b/lib/diaspora_federation/properties_dsl.rb @@ -158,9 +158,7 @@ module DiasporaFederation # @param [Symbol] alias_name alias name def define_alias(name, alias_name) class_prop_aliases[alias_name] = name - # rubocop:disable Style/Alias instance_eval { alias_method alias_name, name } - # rubocop:enable Style/Alias end # Raised, if the name is of an unexpected type diff --git a/spec/lib/diaspora_federation/properties_dsl_spec.rb b/spec/lib/diaspora_federation/properties_dsl_spec.rb index 9ad76ef..d7ce682 100644 --- a/spec/lib/diaspora_federation/properties_dsl_spec.rb +++ b/spec/lib/diaspora_federation/properties_dsl_spec.rb @@ -42,7 +42,7 @@ module DiasporaFederation properties = dsl.class_props expect(properties).to have(3).items expect(properties.keys).to include(:test, :asdf, :zzzz) - properties.values.each {|type| expect(type).to eq(:string) } + properties.each_value {|type| expect(type).to eq(:string) } end it "can add an xml name to simple properties with a symbol" do