From fb50ec52b6f58435f0b23394a2ddec5a8201e3ff Mon Sep 17 00:00:00 2001 From: Philip Harrison Date: Thu, 16 Jul 2020 12:50:47 +0100 Subject: [PATCH] Bump rubocop to 0.88.0 --- .rubocop.yml | 44 ++++++++++++++++--- Rakefile | 2 +- .../update_checker/version_resolver.rb | 2 - .../cargo/file_updater/lockfile_updater.rb | 3 +- .../cargo/update_checker/version_resolver.rb | 5 +-- common/dependabot-common.gemspec | 2 +- common/lib/dependabot/git_metadata_fetcher.rb | 2 - .../metadata_finders/base/changelog_finder.rb | 2 - .../hex/update_checker/file_preparer.rb | 2 + .../file_updater/yarn_lockfile_updater.rb | 2 - .../project_file_declaration_finder.rb | 2 + .../nuget/update_checker/repository_finder.rb | 2 + omnibus/Gemfile | 2 +- omnibus/dependabot-omnibus.gemspec | 2 +- python/lib/dependabot/python/version.rb | 2 - .../lib/dependabot/terraform/file_parser.rb | 2 - 16 files changed, 51 insertions(+), 27 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0bf74e88c28..0b55c74e55f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ Layout/DotPosition: EnforcedStyle: trailing Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false + Enabled: false Layout/LineLength: Max: 80 @@ -21,7 +21,7 @@ Layout/RescueEnsureAlignment: Enabled: false Layout/SpaceAroundMethodCallOperator: - Enabled: false + Enabled: false Lint/DeprecatedOpenSSLConstant: Enabled: false @@ -42,7 +42,7 @@ Metrics/ModuleLength: Max: 350 Metrics/CyclomaticComplexity: - Max: 10 + Max: 15 Metrics/AbcSize: Max: 35 @@ -73,14 +73,14 @@ Style/Documentation: Enabled: false Style/HashEachMethods: - Enabled: false + Enabled: false Style/HashTransformKeys: Enabled: false - + Style/HashTransformValues: Enabled: false - + Style/PercentLiteralDelimiters: PreferredDelimiters: '%i': () @@ -98,4 +98,34 @@ Style/RedundantRegexpEscape: Enabled: false Style/SlicingWithRange: - Enabled: false \ No newline at end of file + Enabled: false + +Style/RedundantFetchBlock: + Enabled: false + +Lint/DuplicateElsifCondition: + Enabled: false + +Style/AccessorGrouping: + Enabled: false + +Style/ArrayCoercion: + Enabled: false + +Style/BisectedAttrAccessor: + Enabled: false + +Style/CaseLikeIf: + Enabled: false + +Style/HashAsLastArrayItem: + Enabled: false + +Style/HashLikeCase: + Enabled: false + +Style/RedundantAssignment: + Enabled: false + +Style/RedundantFileExtensionInRequire: + Enabled: false diff --git a/Rakefile b/Rakefile index 116880b0a90..d9c13c63396 100644 --- a/Rakefile +++ b/Rakefile @@ -41,7 +41,7 @@ namespace :ci do packages = changed_packages puts "Running rubocop on: #{packages.join(', ')}" packages.each do |package| - run_command("cd #{package} && bundle exec rubocop") + run_command("cd #{package} && bundle exec rubocop -c ../.rubocop.yml") end end diff --git a/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb b/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb index 88cb64dfd3f..856dde1ed71 100644 --- a/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb +++ b/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb @@ -71,7 +71,6 @@ def dependency_files ).prepared_dependency_files end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def fetch_latest_resolvable_version_details return latest_version_details unless gemfile @@ -117,7 +116,6 @@ def fetch_latest_resolvable_version_details @gemspec_ruby_unlocked = true regenerate_dependency_files_without_ruby_lock && retry end - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def circular_dependency_at_new_version?(error) diff --git a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb index e83b3db2d95..01c93a59be2 100644 --- a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb +++ b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb @@ -67,6 +67,7 @@ def handle_cargo_error(error) end # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/CyclomaticComplexity def better_specification_needed?(error) return false if @custom_specification return false unless error.message.match?(/specification .* is ambigu/) @@ -95,7 +96,7 @@ def better_specification_needed?(error) @custom_specification = spec_options.first true end - + # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def dependency_spec diff --git a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb index 8b3eb8bc209..b74c1bb6220 100644 --- a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb +++ b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb @@ -79,6 +79,7 @@ def fetch_version_from_new_lockfile end # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/CyclomaticComplexity def better_specification_needed?(error) return false if @custom_specification return false unless error.message.match?(/specification .* is ambigu/) @@ -107,7 +108,7 @@ def better_specification_needed?(error) @custom_specification = spec_options.first true end - + # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def dependency_spec @@ -169,7 +170,6 @@ def check_rust_workspace_root end # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/MethodLength def handle_cargo_errors(error) @@ -238,7 +238,6 @@ def handle_cargo_errors(error) raise error end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/MethodLength diff --git a/common/dependabot-common.gemspec b/common/dependabot-common.gemspec index 4d00a4e43ed..bccdee8ba88 100644 --- a/common/dependabot-common.gemspec +++ b/common/dependabot-common.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rspec", "~> 3.8" spec.add_development_dependency "rspec-its", "~> 1.2" spec.add_development_dependency "rspec_junit_formatter", "~> 0.4" - spec.add_development_dependency "rubocop", "~> 0.85.0" + spec.add_development_dependency "rubocop", "~> 0.88.0" spec.add_development_dependency "vcr", "6.0.0" spec.add_development_dependency "webmock", "~> 3.4" diff --git a/common/lib/dependabot/git_metadata_fetcher.rb b/common/lib/dependabot/git_metadata_fetcher.rb index 51a6cbdd40d..78eb8ba0fac 100644 --- a/common/lib/dependabot/git_metadata_fetcher.rb +++ b/common/lib/dependabot/git_metadata_fetcher.rb @@ -47,7 +47,6 @@ def head_commit_for_ref(ref) attr_reader :url, :credentials - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def fetch_upload_pack_for(uri) response = fetch_raw_upload_pack_for(uri) @@ -79,7 +78,6 @@ def fetch_upload_pack_for(uri) raise Dependabot::GitDependenciesNotReachable, [uri] end - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def fetch_raw_upload_pack_for(uri) diff --git a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb index 940478c4253..ec0a90eafef 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb @@ -76,7 +76,6 @@ def upgrade_guide_text private - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def changelog return unless changelog_from_suggested_url || source @@ -98,7 +97,6 @@ def changelog # Fall back to the changelog (or nil) from the default branch default_branch_changelog end - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def changelog_from_suggested_url diff --git a/hex/lib/dependabot/hex/update_checker/file_preparer.rb b/hex/lib/dependabot/hex/update_checker/file_preparer.rb index d20edd98004..e669af91ec7 100644 --- a/hex/lib/dependabot/hex/update_checker/file_preparer.rb +++ b/hex/lib/dependabot/hex/update_checker/file_preparer.rb @@ -94,6 +94,7 @@ def updated_version_requirement_string(filename) # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/CyclomaticComplexity def updated_version_req_lower_bound(filename) original_req = dependency.requirements. find { |r| r.fetch(:file) == filename }&. @@ -120,6 +121,7 @@ def updated_version_req_lower_bound(filename) ">= #{parts.join('.')}" end end + # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/PerceivedComplexity diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb index 155a6bc3b71..b872726339e 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb @@ -163,7 +163,6 @@ def requirements_for_path(requirements, path) end # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/MethodLength def handle_yarn_lock_updater_error(error, yarn_lock) @@ -255,7 +254,6 @@ def handle_yarn_lock_updater_error(error, yarn_lock) raise error end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/MethodLength diff --git a/nuget/lib/dependabot/nuget/file_updater/project_file_declaration_finder.rb b/nuget/lib/dependabot/nuget/file_updater/project_file_declaration_finder.rb index d9018954d6d..d4b99072405 100644 --- a/nuget/lib/dependabot/nuget/file_updater/project_file_declaration_finder.rb +++ b/nuget/lib/dependabot/nuget/file_updater/project_file_declaration_finder.rb @@ -50,6 +50,7 @@ def get_element_from_node(node) node.at_xpath("/DevelopmentDependency") end + # rubocop:disable Metrics/CyclomaticComplexity def fetch_declaration_strings deep_find_declarations(declaring_file.content).select do |nd| node = Nokogiri::XML(nd) @@ -66,6 +67,7 @@ def fetch_declaration_strings node_requirement == declaring_requirement.fetch(:requirement) end end + # rubocop:enable Metrics/CyclomaticComplexity def get_node_version_value(node) attribute = "Version" diff --git a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb index 73ab60b4bb6..cdb10d0c509 100644 --- a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb +++ b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb @@ -147,6 +147,7 @@ def config_file_repositories config_files.flat_map { |file| repos_from_config_file(file) } end + # rubocop:disable Metrics/CyclomaticComplexity def repos_from_config_file(config_file) doc = Nokogiri::XML(config_file.content) doc.remove_namespaces! @@ -178,6 +179,7 @@ def repos_from_config_file(config_file) sources end + # rubocop:enable Metrics/CyclomaticComplexity def default_repository_details { diff --git a/omnibus/Gemfile b/omnibus/Gemfile index 62a940334fe..3eb8030952f 100644 --- a/omnibus/Gemfile +++ b/omnibus/Gemfile @@ -9,8 +9,8 @@ gem "dependabot-composer", path: "../composer" gem "dependabot-dep", path: "../dep" gem "dependabot-docker", path: "../docker" gem "dependabot-elm", path: "../elm" -gem "dependabot-git_submodules", path: "../git_submodules" gem "dependabot-github_actions", path: "../github_actions" +gem "dependabot-git_submodules", path: "../git_submodules" gem "dependabot-go_modules", path: "../go_modules" gem "dependabot-gradle", path: "../gradle" gem "dependabot-hex", path: "../hex" diff --git a/omnibus/dependabot-omnibus.gemspec b/omnibus/dependabot-omnibus.gemspec index 82c88567b0c..95e1b553045 100644 --- a/omnibus/dependabot-omnibus.gemspec +++ b/omnibus/dependabot-omnibus.gemspec @@ -27,8 +27,8 @@ Gem::Specification.new do |spec| spec.add_dependency "dependabot-dep", Dependabot::VERSION spec.add_dependency "dependabot-docker", Dependabot::VERSION spec.add_dependency "dependabot-elm", Dependabot::VERSION - spec.add_dependency "dependabot-git_submodules", Dependabot::VERSION spec.add_dependency "dependabot-github_actions", Dependabot::VERSION + spec.add_dependency "dependabot-git_submodules", Dependabot::VERSION spec.add_dependency "dependabot-go_modules", Dependabot::VERSION spec.add_dependency "dependabot-gradle", Dependabot::VERSION spec.add_dependency "dependabot-hex", Dependabot::VERSION diff --git a/python/lib/dependabot/python/version.rb b/python/lib/dependabot/python/version.rb index 407b435b310..604f35d9d57 100644 --- a/python/lib/dependabot/python/version.rb +++ b/python/lib/dependabot/python/version.rb @@ -114,7 +114,6 @@ def normalise_prerelease(version) # TODO: Delete this once we're using a version of Rubygems that includes # https://github.com/rubygems/rubygems/pull/2651 # - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Style/CaseEquality # rubocop:disable Layout/LineLength @@ -146,7 +145,6 @@ def old_comp(other) return 0 end - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Style/CaseEquality # rubocop:enable Layout/LineLength diff --git a/terraform/lib/dependabot/terraform/file_parser.rb b/terraform/lib/dependabot/terraform/file_parser.rb index 4bb55282526..4fbe4432ef9 100644 --- a/terraform/lib/dependabot/terraform/file_parser.rb +++ b/terraform/lib/dependabot/terraform/file_parser.rb @@ -190,7 +190,6 @@ def get_proxied_source(raw_source) end&.attributes&.fetch("content", nil)&.value end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def source_type(source_string) return :path if source_string.start_with?(".") @@ -213,7 +212,6 @@ def source_type(source_string) raise "HTTP source, but not an archive!" end - # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity def parsed_file(file)