From 08c679d9742ec87a74021fb737fa177c700e5dc4 Mon Sep 17 00:00:00 2001 From: Philip Harrison Date: Fri, 20 Dec 2019 10:24:19 +0000 Subject: [PATCH] Relax rubocop rules --- .rubocop.yml | 18 +++---- Rakefile | 8 ++-- bin/dry-run.rb | 48 ++++++++++++++----- .../bundler/file_updater/lockfile_updater.rb | 3 -- .../lib/dependabot/bundler/update_checker.rb | 3 -- .../update_checker/requirements_updater.rb | 7 +-- .../update_checker/version_resolver.rb | 3 +- cargo/lib/dependabot/cargo/file_fetcher.rb | 6 +-- .../cargo/file_updater/lockfile_updater.rb | 8 +--- .../cargo/update_checker/version_resolver.rb | 8 +--- common/lib/dependabot/file_fetchers/base.rb | 2 - .../file_parsers/base/dependency_set.rb | 5 +- common/lib/dependabot/git_commit_checker.rb | 3 -- .../metadata_finders/base/changelog_finder.rb | 3 -- .../metadata_finders/base/changelog_pruner.rb | 5 +- .../metadata_finders/base/commits_finder.rb | 5 +- .../pull_request_creator/branch_namer.rb | 5 +- .../dependabot/pull_request_creator/github.rb | 5 -- .../pull_request_creator/labeler.rb | 6 +-- .../pull_request_creator/message_builder.rb | 5 +- .../link_and_mention_sanitizer.rb | 4 +- .../pull_request_creator/pr_name_prefixer.rb | 3 -- common/lib/dependabot/shared_helpers.rb | 6 --- common/lib/dependabot/source.rb | 2 - .../message_builder_spec.rb | 3 -- .../github/commit_compare_diverged.json | 2 +- .../lib/dependabot/composer/file_parser.rb | 3 +- .../lib/dependabot/composer/requirement.rb | 3 +- .../update_checker/requirements_updater.rb | 2 - .../update_checker/version_resolver.rb | 9 +--- .../dep/file_updater/manifest_updater.rb | 3 +- dep/lib/dependabot/dep/update_checker.rb | 3 +- .../github/commit_compare_diverged.json | 2 +- .../github_actions/update_checker.rb | 3 +- .../github/commit_compare_diverged.json | 2 +- .../lib/dependabot/go_modules/file_parser.rb | 3 -- gradle/lib/dependabot/gradle/file_parser.rb | 2 - .../update_checker/requirements_updater.rb | 4 +- .../dependabot/npm_and_yarn/file_fetcher.rb | 5 +- .../file_updater/yarn_lockfile_updater.rb | 3 +- .../dependabot/npm_and_yarn/requirement.rb | 2 - .../update_checker/latest_version_finder.rb | 3 -- .../subdependency_version_resolver.rb | 3 +- .../update_checker/version_resolver.rb | 5 +- .../github/commit_compare_diverged.json | 2 +- nuget/lib/dependabot/nuget/metadata_finder.rb | 2 - .../nuget/update_checker/repository_finder.rb | 2 - .../nuget/update_checker/version_finder.rb | 3 +- nuget/lib/dependabot/nuget/version.rb | 3 +- python/lib/dependabot/python/file_fetcher.rb | 3 -- .../file_updater/pip_compile_file_updater.rb | 4 -- .../file_updater/pipfile_file_updater.rb | 2 - .../pip_compile_version_resolver.rb | 7 +-- .../update_checker/poetry_version_resolver.rb | 2 - .../update_checker/requirements_updater.rb | 3 +- python/lib/dependabot/python/version.rb | 4 +- 56 files changed, 86 insertions(+), 187 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c5cd8af233..3cdda1ebfe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,33 +5,35 @@ AllCops: - '*/vendor/**/*' - '*/bin/**/*' - '*/tmp/**/*' + - 'tmp/**/*' - '*/helpers/**/*' Layout/DotPosition: EnforcedStyle: trailing +Layout/LineLength: + Max: 80 + Layout/RescueEnsureAlignment: Enabled: false Metrics/ClassLength: - Max: 250 + Max: 350 Metrics/ModuleLength: - Max: 200 + Max: 350 Metrics/CyclomaticComplexity: - Max: 7 - -Metrics/LineLength: - Max: 80 + Max: 10 Metrics/AbcSize: - Max: 30 + Max: 35 Metrics/MethodLength: - Max: 25 + Max: 35 Metrics/BlockLength: + Max: 35 Exclude: - '*/Rakefile' - '*/spec/**/*' diff --git a/Rakefile b/Rakefile index 4b740d26ee..116880b0a9 100644 --- a/Rakefile +++ b/Rakefile @@ -54,6 +54,7 @@ namespace :ci do end end +# rubocop:disable Metrics/BlockLength namespace :gems do task build: :clean do root_path = Dir.getwd @@ -89,8 +90,8 @@ namespace :gems do begin sh "gem push #{gem_path}" break - rescue => err - puts "! `gem push` failed with error: #{err}" + rescue StandardError => e + puts "! `gem push` failed with error: #{e}" raise if attempts >= 3 end end @@ -125,7 +126,6 @@ def rubygems_release_exists?(name, version) existing_versions.include?(version) end -# rubocop:disable Metrics/MethodLength def changed_packages all_packages = GEMSPECS. select { |gs| gs.include?("/") }. @@ -163,9 +163,9 @@ def changed_packages packages end -# rubocop:enable Metrics/MethodLength def commit_range_changes_paths?(range, paths) cmd = %w(git diff --quiet) + [range, "--"] + paths !system(Shellwords.join(cmd)) end +# rubocop:enable Metrics/BlockLength diff --git a/bin/dry-run.rb b/bin/dry-run.rb index 76b19498b6..d72e8b4a2f 100755 --- a/bin/dry-run.rb +++ b/bin/dry-run.rb @@ -34,6 +34,8 @@ # - docker # - terraform +# rubocop:disable Style/GlobalVars + $LOAD_PATH << "./bundler/lib" $LOAD_PATH << "./cargo/lib" $LOAD_PATH << "./common/lib" @@ -110,7 +112,8 @@ unless ENV["LOCAL_CONFIG_VARIABLES"].to_s.strip.empty? # For example: - # "[{\"type\":\"npm_registry\",\"registry\":\"registry.npmjs.org\",\"token\":\"123\"}]" + # "[{\"type\":\"npm_registry\",\"registry\":\ + # "registry.npmjs.org\",\"token\":\"123\"}]" $options[:credentials].concat(JSON.parse(ENV["LOCAL_CONFIG_VARIABLES"])) end @@ -133,7 +136,7 @@ $options[:cache_steps].concat(value.split(",").map(&:strip)) end - opts.on("--write", "Write the update to the cache directory") do |value| + opts.on("--write", "Write the update to the cache directory") do |_value| $options[:write] = true end @@ -141,9 +144,9 @@ $options[:lockfile_only] = value end - opts_req_description = "Options: auto, widen_ranges, bump_versions or "\ + opts_req_desc = "Options: auto, widen_ranges, bump_versions or "\ "bump_versions_if_necessary" - opts.on("--requirements-update-strategy STRATEGY", opts_req_description) do |value| + opts.on("--requirements-update-strategy STRATEGY", opts_req_desc) do |value| value = nil if value == "auto" $options[:requirements_update_strategy] = value end @@ -193,8 +196,11 @@ def cached_read(name) cache_dir = File.dirname(cache_path) FileUtils.mkdir_p(cache_dir) unless Dir.exist?(cache_dir) cached = File.read(cache_path) if File.exist?(cache_path) + # rubocop:disable Security/MarshalLoad return Marshal.load(cached) if cached + # rubocop:enable Security/MarshalLoad + data = yield File.write(cache_path, Marshal.dump(data)) data @@ -206,15 +212,23 @@ def dependency_files_cache_dir File.join("dry-run", $repo_name.split("/"), branch, dir) end +# rubocop:disable Metrics/AbcSize +# rubocop:disable Metrics/MethodLength +# rubocop:disable Metrics/CyclomaticComplexity +# rubocop:disable Metrics/PerceivedComplexity def cached_dependency_files_read cache_dir = dependency_files_cache_dir - cache_manifest_path = File.join(cache_dir, "cache-manifest-#{$package_manager}.json") + cache_manifest_path = File.join( + cache_dir, "cache-manifest-#{$package_manager}.json" + ) FileUtils.mkdir_p(cache_dir) unless Dir.exist?(cache_dir) - cached_manifest = File.read(cache_manifest_path) if File.exist?(cache_manifest_path) + if File.exist?(cache_manifest_path) + cached_manifest = File.read(cache_manifest_path) + end cached_dependency_files = JSON.parse(cached_manifest) if cached_manifest - all_files_cached = cached_dependency_files && cached_dependency_files.all? do |file| + all_files_cached = cached_dependency_files&.all? do |file| File.exist?(File.join(cache_dir, file["name"])) end @@ -267,6 +281,10 @@ def cached_dependency_files_read data end end +# rubocop:enable Metrics/PerceivedComplexity +# rubocop:enable Metrics/CyclomaticComplexity +# rubocop:enable Metrics/MethodLength +# rubocop:enable Metrics/AbcSize source = Dependabot::Source.new( provider: "github", @@ -278,7 +296,7 @@ def cached_dependency_files_read $files = cached_dependency_files_read do fetcher = Dependabot::FileFetchers.for_package_manager($package_manager). - new(source: source, credentials: $options[:credentials]) + new(source: source, credentials: $options[:credentials]) fetcher.files end @@ -305,7 +323,7 @@ def update_checker_for(dependency) credentials: $options[:credentials], requirements_update_strategy: $options[:requirements_update_strategy], ignored_versions: ignore_conditions_for(dependency), - security_advisories: security_advisories_for(dependency), + security_advisories: security_advisories_for(dependency) ) end @@ -347,7 +365,7 @@ def peer_dependencies_can_update?(checker, reqs_to_unlock) name: dep.name, version: dep.previous_version, requirements: dep.previous_requirements, - package_manager: dep.package_manager, + package_manager: dep.package_manager ) update_checker_for(original_peer_dep). can_update?(requirements_to_unlock: :own) @@ -379,6 +397,7 @@ def generate_dependency_files_for(updated_dependencies) puts "=> updating #{dependencies.count} dependencies" +# rubocop:disable Metrics/BlockLength dependencies.each do |dep| puts "\n=== #{dep.name} (#{dep.version})" checker = update_checker_for(dep) @@ -405,7 +424,8 @@ def generate_dependency_files_for(updated_dependencies) puts " => requirements to unlock: #{requirements_to_unlock}" if checker.respond_to?(:requirements_update_strategy) - puts " => requirements update strategy: #{checker.requirements_update_strategy}" + puts " => requirements update strategy: "\ + "#{checker.requirements_update_strategy}" end if requirements_to_unlock == :update_not_possible @@ -423,8 +443,9 @@ def generate_dependency_files_for(updated_dependencies) end updated_files = generate_dependency_files_for(updated_deps) + # Currently unused but used to create pull requests (from the updater) - updated_deps = updated_deps.reject do |d| + updated_deps.reject do |d| next false if d.name == checker.dependency.name next true if d.requirements == d.previous_requirements @@ -444,3 +465,6 @@ def generate_dependency_files_for(updated_dependencies) show_diff(original_file, updated_file) end end +# rubocop:enable Metrics/BlockLength + +# rubocop:enable Style/GlobalVars diff --git a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb index 8a485b15c6..4b152ba5f9 100644 --- a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb +++ b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb @@ -10,8 +10,6 @@ require "dependabot/errors" require "dependabot/bundler/file_updater" require "dependabot/git_commit_checker" - -# rubocop:disable Metrics/ClassLength module Dependabot module Bundler class FileUpdater @@ -458,4 +456,3 @@ def using_bundler_2? end end end -# rubocop:enable Metrics/ClassLength diff --git a/bundler/lib/dependabot/bundler/update_checker.rb b/bundler/lib/dependabot/bundler/update_checker.rb index 8a2558cf52..3fc9b88774 100644 --- a/bundler/lib/dependabot/bundler/update_checker.rb +++ b/bundler/lib/dependabot/bundler/update_checker.rb @@ -5,8 +5,6 @@ require "dependabot/bundler/file_updater/requirement_replacer" require "dependabot/bundler/version" require "dependabot/git_commit_checker" - -# rubocop:disable Metrics/ClassLength module Dependabot module Bundler class UpdateChecker < Dependabot::UpdateCheckers::Base @@ -389,7 +387,6 @@ def prepared_dependency_files(remove_git_source:, unlock_requirement:, end end end -# rubocop:enable Metrics/ClassLength Dependabot::UpdateCheckers. register("bundler", Dependabot::Bundler::UpdateChecker) diff --git a/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb b/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb index 0cb4cfed04..a7cd7bdd1c 100644 --- a/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb +++ b/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb @@ -126,7 +126,6 @@ def at_same_precision(new_version, old_version) end # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def update_gemspec_requirement(req) req = req.merge(source: updated_source) if req.fetch(:source) return req unless latest_version && latest_resolvable_version @@ -153,7 +152,6 @@ def update_gemspec_requirement(req) req.merge(requirement: :unfixable) end # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity def requirement_satisfied?(req, groups) if groups == ["development"] @@ -216,7 +214,6 @@ def bumped_requirements(req) end end - # rubocop:disable Metrics/AbcSize def convert_twidle_to_range(requirement, version_to_be_permitted) version = requirement.requirements.first.last version = version.release if version.prerelease? @@ -245,7 +242,6 @@ def convert_twidle_to_range(requirement, version_to_be_permitted) Gem::Requirement.new("< #{ub_segments.join('.')}") ] end - # rubocop:enable Metrics/AbcSize # Updates the version in a "~>" constraint to allow the given version def update_twiddle_version(requirement, version_to_be_permitted) @@ -256,7 +252,6 @@ def update_twiddle_version(requirement, version_to_be_permitted) # Updates the version in a "<" or "<=" constraint to allow the given # version - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity def update_greatest_version(requirement, version_to_be_permitted) if version_to_be_permitted.is_a?(String) @@ -283,7 +278,7 @@ def update_greatest_version(requirement, version_to_be_permitted) Gem::Requirement.new("#{op} #{new_segments.join('.')}") end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/PerceivedComplexity 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 2eb6667046..c1b83b7976 100644 --- a/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb +++ b/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb @@ -154,7 +154,6 @@ def regenerate_dependency_files_without_ruby_lock ).prepared_dependency_files end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def dependency_from_definition(unlock_subdependencies: true) dependencies_to_unlock = [dependency.name] @@ -181,7 +180,7 @@ def dependency_from_definition(unlock_subdependencies: true) # try again but without unlocking any other sub-dependencies dependency_from_definition(unlock_subdependencies: false) end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def unlock_yanked_gem(dependencies_to_unlock, error) diff --git a/cargo/lib/dependabot/cargo/file_fetcher.rb b/cargo/lib/dependabot/cargo/file_fetcher.rb index 597308872f..3b6c0366fa 100644 --- a/cargo/lib/dependabot/cargo/file_fetcher.rb +++ b/cargo/lib/dependabot/cargo/file_fetcher.rb @@ -98,7 +98,6 @@ def fetch_workspace_files(file:, previously_fetched_files:) files end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def fetch_path_dependency_files(file:, previously_fetched_files:) current_dir = file.name.rpartition("/").first @@ -133,7 +132,7 @@ def fetch_path_dependency_files(file:, previously_fetched_files:) raise Dependabot::PathDependenciesNotReachable, unfetchable_required_path_deps end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def path_dependency_paths_from_file(file) @@ -217,7 +216,6 @@ def workspace_dependency_paths_from_file(file) # Check whether a path is required or not. It will not be required if # an alternative source (i.e., a git source) is also specified - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def required_path?(file, path) @@ -256,7 +254,7 @@ def required_path?(file, path) false end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity diff --git a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb index e93bdcadc3..c1abb710df 100644 --- a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb +++ b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb @@ -7,8 +7,6 @@ require "dependabot/cargo/file_updater/manifest_updater" require "dependabot/cargo/file_parser" require "dependabot/shared_helpers" - -# rubocop:disable Metrics/ClassLength module Dependabot module Cargo class FileUpdater @@ -68,8 +66,6 @@ def handle_cargo_error(error) raise Dependabot::DependencyFileNotResolvable, error.message end - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def better_specification_needed?(error) return false if @custom_specification @@ -99,8 +95,7 @@ def better_specification_needed?(error) @custom_specification = spec_options.first true end - # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def dependency_spec @@ -378,4 +373,3 @@ def virtual_manifest?(file) end end end -# rubocop:enable Metrics/ClassLength diff --git a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb index b13b4434b2..fc4ed4ea25 100644 --- a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb +++ b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb @@ -7,8 +7,6 @@ require "dependabot/cargo/file_parser" require "dependabot/cargo/version" require "dependabot/errors" - -# rubocop:disable Metrics/ClassLength module Dependabot module Cargo class UpdateChecker @@ -80,8 +78,6 @@ def fetch_version_from_new_lockfile end end - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def better_specification_needed?(error) return false if @custom_specification @@ -111,8 +107,7 @@ def better_specification_needed?(error) @custom_specification = spec_options.first true end - # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def dependency_spec @@ -431,4 +426,3 @@ def version_class end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/file_fetchers/base.rb b/common/lib/dependabot/file_fetchers/base.rb index 724ed71136..46cadb3189 100644 --- a/common/lib/dependabot/file_fetchers/base.rb +++ b/common/lib/dependabot/file_fetchers/base.rb @@ -351,7 +351,6 @@ def _fetch_file_content_fully_specified(provider, repo, path, commit) end # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/MethodLength def _fetch_file_content_from_github(path, repo, commit) tmp = github_client.contents(repo, path: path, ref: commit) @@ -388,7 +387,6 @@ def _fetch_file_content_from_github(path, repo, commit) Base64.decode64(tmp.content).force_encoding("UTF-8").encode end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/MethodLength def default_branch_for_repo @default_branch_for_repo ||= client_for_provider. diff --git a/common/lib/dependabot/file_parsers/base/dependency_set.rb b/common/lib/dependabot/file_parsers/base/dependency_set.rb index 5fc0fb35f8..7d87465b20 100644 --- a/common/lib/dependabot/file_parsers/base/dependency_set.rb +++ b/common/lib/dependabot/file_parsers/base/dependency_set.rb @@ -60,8 +60,6 @@ def dependency_for_name(name) dependencies.find { |d| d.name&.downcase == name&.downcase } end - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def combined_dependency(old_dep, new_dep) package_manager = old_dep.package_manager @@ -91,8 +89,7 @@ def combined_dependency(old_dep, new_dep) subdependency_metadata: subdependency_metadata ) end - # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity end end diff --git a/common/lib/dependabot/git_commit_checker.rb b/common/lib/dependabot/git_commit_checker.rb index 1699f75b9a..2a3e08d72b 100644 --- a/common/lib/dependabot/git_commit_checker.rb +++ b/common/lib/dependabot/git_commit_checker.rb @@ -11,8 +11,6 @@ require "dependabot/source" require "dependabot/dependency" require "dependabot/git_metadata_fetcher" - -# rubocop:disable Metrics/ClassLength module Dependabot class GitCommitChecker VERSION_REGEX = / @@ -362,4 +360,3 @@ def listing_repo_git_metadata_fetcher end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb index 17c2e1f300..113d7d14d3 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb @@ -8,8 +8,6 @@ require "dependabot/clients/bitbucket_with_retries" require "dependabot/shared_helpers" require "dependabot/metadata_finders/base" - -# rubocop:disable Metrics/ClassLength module Dependabot module MetadataFinders class Base @@ -382,4 +380,3 @@ def default_bitbucket_branch end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb b/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb index b7e50cf8eb..ab62289b07 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb @@ -22,7 +22,6 @@ def includes_previous_version? end # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def pruned_text changelog_lines = changelog_text.split("\n") @@ -53,7 +52,6 @@ def pruned_text changelog_lines.slice(slice_range).join("\n").sub(/\n*\z/, "") end # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity private @@ -70,7 +68,6 @@ def new_version_changelog_line changelog_line_for_version(new_version) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def changelog_line_for_version(version) raise "No changelog text" unless changelog_text @@ -93,7 +90,7 @@ def changelog_line_for_version(version) false end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def changelog_contains_relevant_versions? diff --git a/common/lib/dependabot/metadata_finders/base/commits_finder.rb b/common/lib/dependabot/metadata_finders/base/commits_finder.rb index 5df0c03bc1..3a52466742 100644 --- a/common/lib/dependabot/metadata_finders/base/commits_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/commits_finder.rb @@ -35,7 +35,6 @@ def commits_url "#{source.url}/#{path}" end - # rubocop:disable Metrics/CyclomaticComplexity def commits return [] unless source return [] unless new_tag && previous_tag @@ -48,7 +47,6 @@ def commits else raise "Unexpected source provider '#{source.provider}'" end end - # rubocop:enable Metrics/CyclomaticComplexity def new_tag new_version = dependency.version @@ -68,7 +66,6 @@ def new_tag private - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def previous_tag previous_version = dependency.previous_version @@ -88,7 +85,7 @@ def previous_tag lowest_tag_satisfying_previous_requirements end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def lowest_tag_satisfying_previous_requirements diff --git a/common/lib/dependabot/pull_request_creator/branch_namer.rb b/common/lib/dependabot/pull_request_creator/branch_namer.rb index 7ec0bb8772..b32f597eb0 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer.rb @@ -17,9 +17,7 @@ def initialize(dependencies:, files:, target_branch:, separator: "/", @prefix = prefix end - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def new_branch_name @name ||= begin @@ -50,9 +48,8 @@ def new_branch_name # Some users need branch names without slashes branch_name.gsub("/", separator) end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity private diff --git a/common/lib/dependabot/pull_request_creator/github.rb b/common/lib/dependabot/pull_request_creator/github.rb index 4e3ff0d5f5..472e91572e 100644 --- a/common/lib/dependabot/pull_request_creator/github.rb +++ b/common/lib/dependabot/pull_request_creator/github.rb @@ -5,8 +5,6 @@ require "dependabot/clients/github_with_retries" require "dependabot/pull_request_creator" require "dependabot/pull_request_creator/commit_signer" - -# rubocop:disable Metrics/ClassLength module Dependabot class PullRequestCreator class Github @@ -405,7 +403,6 @@ def github_client_for_source ) end - # rubocop:disable Metrics/CyclomaticComplexity def handle_error(err) case err when Octokit::Forbidden @@ -425,8 +422,6 @@ def handle_error(err) raise err end end - # rubocop:enable Metrics/CyclomaticComplexity end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/pull_request_creator/labeler.rb b/common/lib/dependabot/pull_request_creator/labeler.rb index 78c3aef0fe..f485cc86f0 100644 --- a/common/lib/dependabot/pull_request_creator/labeler.rb +++ b/common/lib/dependabot/pull_request_creator/labeler.rb @@ -2,8 +2,6 @@ require "octokit" require "dependabot/pull_request_creator" - -# rubocop:disable Metrics/ClassLength module Dependabot class PullRequestCreator class Labeler @@ -89,7 +87,6 @@ def automerge_candidate? @automerge_candidate end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def update_type return unless dependencies.any?(&:previous_version) @@ -112,7 +109,7 @@ def update_type when 3 then "patch" end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def version(dep) @@ -394,4 +391,3 @@ def version_class end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/pull_request_creator/message_builder.rb b/common/lib/dependabot/pull_request_creator/message_builder.rb index 9d46c92bbe..c6d79467dc 100644 --- a/common/lib/dependabot/pull_request_creator/message_builder.rb +++ b/common/lib/dependabot/pull_request_creator/message_builder.rb @@ -72,7 +72,6 @@ def library_pr_name end end - # rubocop:disable Metrics/AbcSize def application_pr_name pr_name = "bump " pr_name = pr_name.capitalize if pr_name_prefixer.capitalize_first_word? @@ -96,7 +95,6 @@ def application_pr_name "#{names[0..-2].join(', ')} and #{names[-1]}" end end - # rubocop:enable Metrics/AbcSize def pr_name_prefix pr_name_prefixer.pr_name_prefix @@ -166,7 +164,6 @@ def requirement_commit_message_intro msg + "to permit the latest version." end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def version_commit_message_intro if dependencies.count > 1 && updating_a_property? @@ -196,7 +193,7 @@ def version_commit_message_intro msg end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def multidependency_property_intro diff --git a/common/lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb b/common/lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb index e79f565a56..27b438631d 100644 --- a/common/lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb +++ b/common/lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb @@ -14,7 +14,7 @@ class LinkAndMentionSanitizer github\.com/(?#{GITHUB_USERNAME}/[^/\s]+)/ (?:issue|pull)s?/(?\d+) }x.freeze - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength # Context: # - https://github.github.com/gfm/#fenced-code-block (``` or ~~~) # (?<=\n|^) Positive look-behind to ensure we start at a line start @@ -25,7 +25,7 @@ class LinkAndMentionSanitizer # (?![^`]*?\n{2,}) Negative look-ahead to avoid empty lines inside code span # (?:.|\n)*? Non-capturing group to consume code span content (non-eager) # (?>\k) Atomic group marking the end of the code span (same length as opening) - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength CODEBLOCK_REGEX = /```|~~~/.freeze # End of string EOS_REGEX = /\z/.freeze diff --git a/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb b/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb index 9dfa9714a3..69c811e772 100644 --- a/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +++ b/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb @@ -5,8 +5,6 @@ require "dependabot/clients/github_with_retries" require "dependabot/clients/gitlab_with_retries" require "dependabot/pull_request_creator" - -# rubocop:disable Metrics/ClassLength module Dependabot class PullRequestCreator class PrNamePrefixer @@ -429,4 +427,3 @@ def package_manager end end end -# rubocop:enable Metrics/ClassLength diff --git a/common/lib/dependabot/shared_helpers.rb b/common/lib/dependabot/shared_helpers.rb index 632192bb09..881dc95d1a 100644 --- a/common/lib/dependabot/shared_helpers.rb +++ b/common/lib/dependabot/shared_helpers.rb @@ -81,7 +81,6 @@ def self.escape_command(command) Shellwords.join(command_parts) end - # rubocop:disable Metrics/MethodLength def self.run_helper_subprocess(command:, function:, args:, env: nil, stderr_to_stdout: false, escape_command_str: true) @@ -119,7 +118,6 @@ def self.run_helper_subprocess(command:, function:, args:, env: nil, error_context: error_context ) end - # rubocop:enable Metrics/MethodLength def self.excon_middleware Excon.defaults[:middlewares] + @@ -167,8 +165,6 @@ def self.configure_git_to_use_https ) end - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/MethodLength def self.configure_git_credentials(credentials) # Then add a file-based credential store that loads a file in this repo. # Under the hood this uses git credential-store, but it's invoked through @@ -212,8 +208,6 @@ def self.configure_git_credentials(credentials) # Save the file File.write("git.store", git_store_content) end - # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/MethodLength def self.stash_global_git_config return unless File.exist?(GIT_CONFIG_GLOBAL_PATH) diff --git a/common/lib/dependabot/source.rb b/common/lib/dependabot/source.rb index 87125a2625..6fd0f8f9a2 100644 --- a/common/lib/dependabot/source.rb +++ b/common/lib/dependabot/source.rb @@ -74,7 +74,6 @@ def url "https://" + hostname + "/" + repo end - # rubocop:disable Metrics/CyclomaticComplexity def url_with_directory return url if [nil, ".", "/"].include?(directory) @@ -94,7 +93,6 @@ def url_with_directory else raise "Unexpected repo provider '#{provider}'" end end - # rubocop:enable Metrics/CyclomaticComplexity def organization repo.split("/").first diff --git a/common/spec/dependabot/pull_request_creator/message_builder_spec.rb b/common/spec/dependabot/pull_request_creator/message_builder_spec.rb index 93ffa60f0a..4f94c6efad 100644 --- a/common/spec/dependabot/pull_request_creator/message_builder_spec.rb +++ b/common/spec/dependabot/pull_request_creator/message_builder_spec.rb @@ -67,8 +67,6 @@ let(:json_header) { { "Content-Type" => "application/json" } } let(:watched_repo_url) { "https://api.github.com/repos/#{source.repo}" } - - # rubocop:disable Metrics/MethodLength def commits_details(base:, head:) "
\n"\ "Commits\n"\ @@ -105,7 +103,6 @@ def commits_details(base:, head:) "\n"\ "
\n" end - # rubocop:enable Metrics/MethodLength describe "#pr_name" do subject(:pr_name) { builder.pr_name } diff --git a/common/spec/fixtures/github/commit_compare_diverged.json b/common/spec/fixtures/github/commit_compare_diverged.json index ed7c5cf28a..a6540c8ff1 100644 --- a/common/spec/fixtures/github/commit_compare_diverged.json +++ b/common/spec/fixtures/github/commit_compare_diverged.json @@ -376,7 +376,7 @@ "blob_url": "https://github.com/gocardless/business/blob/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "raw_url": "https://github.com/gocardless/business/raw/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "contents_url": "https://api.github.com/repos/gocardless/business/contents/.rubocop.yml?ref=ace90dc4d34136a5d9570e54288c505711fb93ce", - "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Metrics/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" + "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Layout/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" }, { "sha": "b4e2a20bb6069d33479542fc863e7e36810e0f01", diff --git a/composer/lib/dependabot/composer/file_parser.rb b/composer/lib/dependabot/composer/file_parser.rb index 0f10e48a62..9aadedec21 100644 --- a/composer/lib/dependabot/composer/file_parser.rb +++ b/composer/lib/dependabot/composer/file_parser.rb @@ -78,7 +78,6 @@ def build_manifest_dependency(name, req, keys) ) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def lockfile_dependencies dependencies = DependencySet.new @@ -104,7 +103,7 @@ def lockfile_dependencies dependencies end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def build_lockfile_dependency(name, version, keys) diff --git a/composer/lib/dependabot/composer/requirement.rb b/composer/lib/dependabot/composer/requirement.rb index d6835c3768..021528c6e3 100644 --- a/composer/lib/dependabot/composer/requirement.rb +++ b/composer/lib/dependabot/composer/requirement.rb @@ -35,7 +35,6 @@ def initialize(*requirements) private - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def convert_php_constraint_to_ruby_constraint(req_string) req_string = req_string.strip.gsub(/v(?=\d)/, "").gsub(/\.$/, "") @@ -53,7 +52,7 @@ def convert_php_constraint_to_ruby_constraint(req_string) else req_string end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def convert_wildcard_req(req_string) diff --git a/composer/lib/dependabot/composer/update_checker/requirements_updater.rb b/composer/lib/dependabot/composer/update_checker/requirements_updater.rb index 7affa3924b..0f3d96bc6c 100644 --- a/composer/lib/dependabot/composer/update_checker/requirements_updater.rb +++ b/composer/lib/dependabot/composer/update_checker/requirements_updater.rb @@ -54,7 +54,6 @@ def check_update_strategy end # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def updated_requirement(req) req_string = req[:requirement].strip or_string_reqs = req_string.split(OR_SEPARATOR) @@ -83,7 +82,6 @@ def updated_requirement(req) new_req.merge(requirement: new_req_string) end # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity def updated_alias(req) req_string = req[:requirement] diff --git a/composer/lib/dependabot/composer/update_checker/version_resolver.rb b/composer/lib/dependabot/composer/update_checker/version_resolver.rb index 0a8c3eecff..c837dde1d5 100644 --- a/composer/lib/dependabot/composer/update_checker/version_resolver.rb +++ b/composer/lib/dependabot/composer/update_checker/version_resolver.rb @@ -8,8 +8,6 @@ require "dependabot/composer/requirement" require "dependabot/composer/native_helpers" require "dependabot/composer/file_parser" - -# rubocop:disable Metrics/ClassLength module Dependabot module Composer class UpdateChecker @@ -166,7 +164,6 @@ def lock_git_dependencies(content) JSON.dump(json) end - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity def updated_version_requirement_string lower_bound = @@ -203,7 +200,7 @@ def updated_version_requirement_string lower_bound + ", <= #{latest_allowable_version}" end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/PerceivedComplexity # rubocop:disable Metrics/PerceivedComplexity @@ -335,7 +332,6 @@ def implicit_platform_reqs_satisfiable?(message) end # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/PerceivedComplexity def check_original_requirements_resolvable base_directory = dependency_files.first.directory @@ -374,7 +370,7 @@ def check_original_requirements_resolvable raise Dependabot::DependencyFileNotResolvable, e.message end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/PerceivedComplexity def version_for_reqs(requirements) @@ -483,4 +479,3 @@ def remove_url_credentials(message) end end end -# rubocop:enable Metrics/ClassLength diff --git a/dep/lib/dependabot/dep/file_updater/manifest_updater.rb b/dep/lib/dependabot/dep/file_updater/manifest_updater.rb index 345759973d..b1bb22ba53 100644 --- a/dep/lib/dependabot/dep/file_updater/manifest_updater.rb +++ b/dep/lib/dependabot/dep/file_updater/manifest_updater.rb @@ -92,7 +92,6 @@ def update_git_pin(content:, filename:, dependency:) ) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def update_manifest_req(content:, dep:, old_req:, new_req:) declaration = content.scan(declaration_regex(dep)). @@ -117,7 +116,7 @@ def update_manifest_req(content:, dep:, old_req:, new_req:) end end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def update_manifest_pin(content:, dep:, old_pin:, new_pin:) diff --git a/dep/lib/dependabot/dep/update_checker.rb b/dep/lib/dependabot/dep/update_checker.rb index 07ea5a59d1..903e769159 100644 --- a/dep/lib/dependabot/dep/update_checker.rb +++ b/dep/lib/dependabot/dep/update_checker.rb @@ -93,7 +93,6 @@ def library? dependency_files.none? { |f| f.type == "package_main" } end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def latest_resolvable_version_for_git_dependency return latest_version if modules_dependency? @@ -127,7 +126,7 @@ def latest_resolvable_version_for_git_dependency # version then there's nothing we can do. nil end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def version_from_tag(tag) diff --git a/dep/spec/fixtures/github/commit_compare_diverged.json b/dep/spec/fixtures/github/commit_compare_diverged.json index ed7c5cf28a..a6540c8ff1 100644 --- a/dep/spec/fixtures/github/commit_compare_diverged.json +++ b/dep/spec/fixtures/github/commit_compare_diverged.json @@ -376,7 +376,7 @@ "blob_url": "https://github.com/gocardless/business/blob/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "raw_url": "https://github.com/gocardless/business/raw/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "contents_url": "https://api.github.com/repos/gocardless/business/contents/.rubocop.yml?ref=ace90dc4d34136a5d9570e54288c505711fb93ce", - "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Metrics/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" + "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Layout/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" }, { "sha": "b4e2a20bb6069d33479542fc863e7e36810e0f01", diff --git a/github_actions/lib/dependabot/github_actions/update_checker.rb b/github_actions/lib/dependabot/github_actions/update_checker.rb index 1a31c8c536..e98873c5f9 100644 --- a/github_actions/lib/dependabot/github_actions/update_checker.rb +++ b/github_actions/lib/dependabot/github_actions/update_checker.rb @@ -78,7 +78,6 @@ def fetch_latest_version_for_git_dependency dependency.version end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def updated_source # TODO: Support Docker sources @@ -101,7 +100,7 @@ def updated_source # Otherwise return the original source dependency_source_details end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def dependency_source_details diff --git a/github_actions/spec/fixtures/github/commit_compare_diverged.json b/github_actions/spec/fixtures/github/commit_compare_diverged.json index ed7c5cf28a..a6540c8ff1 100644 --- a/github_actions/spec/fixtures/github/commit_compare_diverged.json +++ b/github_actions/spec/fixtures/github/commit_compare_diverged.json @@ -376,7 +376,7 @@ "blob_url": "https://github.com/gocardless/business/blob/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "raw_url": "https://github.com/gocardless/business/raw/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "contents_url": "https://api.github.com/repos/gocardless/business/contents/.rubocop.yml?ref=ace90dc4d34136a5d9570e54288c505711fb93ce", - "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Metrics/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" + "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Layout/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" }, { "sha": "b4e2a20bb6069d33479542fc863e7e36810e0f01", diff --git a/go_modules/lib/dependabot/go_modules/file_parser.rb b/go_modules/lib/dependabot/go_modules/file_parser.rb index d4c1aa9abd..bf721e68f9 100644 --- a/go_modules/lib/dependabot/go_modules/file_parser.rb +++ b/go_modules/lib/dependabot/go_modules/file_parser.rb @@ -136,8 +136,6 @@ def go_mod_content end GIT_ERROR_REGEX = /go: .*: git fetch .*: exit status 128/.freeze - - # rubocop:disable Metrics/AbcSize def handle_parser_error(path, stderr) case stderr when /go: .*: unknown revision/ @@ -157,7 +155,6 @@ def handle_parser_error(path, stderr) raise Dependabot::DependencyFileNotParseable.new(go_mod.path, msg) end end - # rubocop:enable Metrics/AbcSize def rev_identifier?(dep) dep["Version"]&.match?(GIT_VERSION_REGEX) diff --git a/gradle/lib/dependabot/gradle/file_parser.rb b/gradle/lib/dependabot/gradle/file_parser.rb index 0ab1597cd1..423c97b9b1 100644 --- a/gradle/lib/dependabot/gradle/file_parser.rb +++ b/gradle/lib/dependabot/gradle/file_parser.rb @@ -168,7 +168,6 @@ def argument_from_string(string, arg_name) fetch("value") end - # rubocop:disable Metrics/MethodLength def dependency_from(details_hash:, buildfile:, in_dependency_set: false) group = evaluated_value(details_hash[:group], buildfile) name = evaluated_value(details_hash[:name], buildfile) @@ -203,7 +202,6 @@ def dependency_from(details_hash:, buildfile:, in_dependency_set: false) package_manager: "gradle" ) end - # rubocop:enable Metrics/MethodLength def source_from(group, name, version) return nil unless group&.start_with?("com.github") diff --git a/hex/lib/dependabot/hex/update_checker/requirements_updater.rb b/hex/lib/dependabot/hex/update_checker/requirements_updater.rb index 4b0b247036..5ed7696d43 100644 --- a/hex/lib/dependabot/hex/update_checker/requirements_updater.rb +++ b/hex/lib/dependabot/hex/update_checker/requirements_updater.rb @@ -32,8 +32,6 @@ def updated_requirements private attr_reader :requirements, :latest_resolvable_version, :updated_source - - # rubocop:disable Metrics/AbcSize # rubocop:disable PerceivedComplexity def updated_mixfile_requirement(req) req = update_source(req) @@ -61,7 +59,7 @@ def updated_mixfile_requirement(req) req.merge(requirement: new_requirement) end - # rubocop:enable Metrics/AbcSize + # rubocop:enable PerceivedComplexity def update_source(requirement_hash) diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb index 1a298318fc..d0e7c91e66 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb @@ -7,7 +7,6 @@ module Dependabot module NpmAndYarn - # rubocop:disable Metrics/ClassLength class FileFetcher < Dependabot::FileFetchers::Base require_relative "file_fetcher/path_dependency_builder" @@ -32,7 +31,6 @@ def self.required_files_message private - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def fetch_files fetched_files = [] @@ -49,7 +47,7 @@ def fetch_files fetched_files.uniq end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def package_json @@ -373,7 +371,6 @@ def parsed_lerna_json raise Dependabot::DependencyFileNotParseable, lerna_json.path end end - # rubocop:enable Metrics/ClassLength end end 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 dc637f6a21..155a6bc3b7 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 @@ -99,7 +99,6 @@ def run_previous_yarn_update(path:, lockfile_name:) ) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def run_yarn_updater(path:, lockfile_name:, top_level_dependency_updates:) @@ -131,7 +130,7 @@ def run_yarn_updater(path:, lockfile_name:, sleep(rand(3.0..10.0)) && retry end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def run_yarn_top_level_updater(top_level_dependency_updates:) diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb index 737f9659e6..3a6d164cad 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb @@ -57,7 +57,6 @@ def initialize(*requirements) private # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity def convert_js_constraint_to_ruby_constraint(req_string) return req_string if req_string.match?(/^([A-Za-uw-z]|v[^\d])/) @@ -74,7 +73,6 @@ def convert_js_constraint_to_ruby_constraint(req_string) end end # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity def convert_tilde_req(req_string) version = req_string.gsub(/^~\>?[\s=]*/, "") diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/latest_version_finder.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/latest_version_finder.rb index aedb8320e4..de99d0a633 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/latest_version_finder.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/latest_version_finder.rb @@ -7,8 +7,6 @@ require "dependabot/npm_and_yarn/requirement" require "dependabot/shared_helpers" require "dependabot/errors" - -# rubocop:disable ClassLength module Dependabot module NpmAndYarn class UpdateChecker @@ -408,4 +406,3 @@ def git_dependency? end end end -# rubocop:enable ClassLength diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb index ec898888b2..f6636d18e0 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb @@ -82,7 +82,6 @@ def version_from_updated_lockfiles(updated_lockfiles) version_class.new(updated_version) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def run_yarn_updater(path, lockfile_name) SharedHelpers.with_git_configured(credentials: credentials) do @@ -107,7 +106,7 @@ def run_yarn_updater(path, lockfile_name) sleep(rand(3.0..10.0)) && retry end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def run_npm_updater(path, lockfile_name) diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb index 5e6caa6a16..461fe09c57 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb @@ -77,7 +77,6 @@ def latest_resolvable_previous_version(updated_version) resolve_latest_previous_version(dependency, updated_version) end - # rubocop:disable Metrics/MethodLength def dependency_updates_from_full_unlock return if git_dependency?(dependency) if part_of_tightly_locked_monorepo? @@ -114,7 +113,6 @@ def dependency_updates_from_full_unlock end updates.uniq end - # rubocop:enable Metrics/MethodLength private @@ -302,7 +300,6 @@ def relevant_unmet_peer_dependencies end end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def satisfying_versions latest_version_finder(dependency). @@ -327,7 +324,7 @@ def satisfying_versions end. map(&:first) end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def satisfies_peer_reqs_on_dep?(version) diff --git a/npm_and_yarn/spec/fixtures/github/commit_compare_diverged.json b/npm_and_yarn/spec/fixtures/github/commit_compare_diverged.json index ed7c5cf28a..a6540c8ff1 100644 --- a/npm_and_yarn/spec/fixtures/github/commit_compare_diverged.json +++ b/npm_and_yarn/spec/fixtures/github/commit_compare_diverged.json @@ -376,7 +376,7 @@ "blob_url": "https://github.com/gocardless/business/blob/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "raw_url": "https://github.com/gocardless/business/raw/ace90dc4d34136a5d9570e54288c505711fb93ce/.rubocop.yml", "contents_url": "https://api.github.com/repos/gocardless/business/contents/.rubocop.yml?ref=ace90dc4d34136a5d9570e54288c505711fb93ce", - "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Metrics/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" + "patch": "@@ -0,0 +1,122 @@\n+AllCops:\n+ TargetRubyVersion: 2.1\n+ DisplayCopNames: true\n+\n+Lint/UnneededDisable:\n+ Severity: error\n+\n+Metrics/AbcSize:\n+ Max: 59\n+\n+Metrics/CyclomaticComplexity:\n+ Max: 10\n+\n+Metrics/PerceivedComplexity:\n+ Max: 9\n+\n+Metrics/ClassLength:\n+ Enabled: false\n+\n+Layout/LineLength:\n+ Max: 90\n+ Exclude:\n+ - Gemfile\n+\n+Metrics/BlockLength:\n+ Exclude:\n+ - business.gemspec\n+ - spec/*\n+ - spec/**/*\n+\n+# Avoid methods longer than 30 lines of code\n+Metrics/MethodLength:\n+ CountComments: false # count full line comments?\n+ Max: 87\n+\n+Metrics/ModuleLength:\n+ Enabled: false\n+\n+Metrics/ParameterLists:\n+ CountKeywordArgs: false\n+\n+# Allow non-ASCII characters (e.g. £) in comments\n+Style/AsciiComments:\n+ Enabled: false\n+\n+Style/Alias:\n+ Enabled: true\n+ EnforcedStyle: prefer_alias_method\n+\n+# Use trailing rather than leading dots on multi-line call chains\n+Style/DotPosition:\n+ EnforcedStyle: trailing\n+\n+# Magic encoding comment only relevant on ruby-1.9 or non-utf8\n+Style/Encoding:\n+ Enabled: never\n+\n+Style/Documentation:\n+ Enabled: false\n+\n+Style/FormatString:\n+ EnforcedStyle: sprintf\n+\n+Style/FrozenStringLiteralComment:\n+ Enabled: always\n+\n+Style/TrailingCommaInLiteral:\n+ EnforcedStyleForMultiline: comma\n+\n+Style/TrailingCommaInArguments:\n+ EnforcedStyleForMultiline: comma\n+\n+# As of 0.43.0 this cop complains in situations where a guard clause would be\n+# unhelpful or erroneous.\n+# The auto-correct is also buggy.\n+Style/GuardClause:\n+ Enabled: false\n+\n+Style/IndentArray:\n+ EnforcedStyle: consistent\n+\n+Style/IndentHash:\n+ EnforcedStyle: consistent\n+\n+Style/Lambda:\n+ EnforcedStyle: literal\n+\n+Style/MultilineMethodCallIndentation:\n+ EnforcedStyle: indented\n+\n+Style/MultilineOperationIndentation:\n+ EnforcedStyle: indented\n+\n+Style/NumericPredicate:\n+ Exclude:\n+ - 'spec/**/*'\n+\n+Style/NumericLiterals:\n+ MinDigits: 11\n+\n+# As of 0.43.0 this cop has many false positives\n+# https://github.com/bbatsov/rubocop/pull/3517 may fix a lot of these\n+Style/SafeNavigation:\n+ Enabled: false\n+\n+Style/SignalException:\n+ EnforcedStyle: 'only_raise'\n+\n+# Wants you to use the same argument names for every reduce. This seems kinda\n+# naff compared to naming them semantically\n+Style/SingleLineBlockParams:\n+ Enabled: false\n+\n+Style/StringLiterals:\n+ EnforcedStyle: 'double_quotes'\n+\n+Style/VariableNumber:\n+ Enabled: false\n+\n+Style/FileName:\n+ Exclude:\n+ - 'Gemfile'" }, { "sha": "b4e2a20bb6069d33479542fc863e7e36810e0f01", diff --git a/nuget/lib/dependabot/nuget/metadata_finder.rb b/nuget/lib/dependabot/nuget/metadata_finder.rb index 3ffcf8b87b..a6420d4982 100644 --- a/nuget/lib/dependabot/nuget/metadata_finder.rb +++ b/nuget/lib/dependabot/nuget/metadata_finder.rb @@ -55,7 +55,6 @@ def dependency_nuspec_file @dependency_nuspec_file = Nokogiri::XML(response.body) end - # rubocop:disable Metrics/AbcSize def dependency_nuspec_url source = dependency.requirements. find { |r| r&.fetch(:source) }&.fetch(:source) @@ -76,7 +75,6 @@ def dependency_nuspec_url "#{dependency.name.downcase}.nuspec" end end - # rubocop:enable Metrics/AbcSize def dependency_source_url source = dependency.requirements. diff --git a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb index 93c97173ab..73ab60b4bb 100644 --- a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb +++ b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb @@ -147,7 +147,6 @@ def config_file_repositories config_files.flat_map { |file| repos_from_config_file(file) } end - # rubocop:disable Metrics/AbcSize def repos_from_config_file(config_file) doc = Nokogiri::XML(config_file.content) doc.remove_namespaces! @@ -179,7 +178,6 @@ def repos_from_config_file(config_file) sources end - # rubocop:enable Metrics/AbcSize def default_repository_details { diff --git a/nuget/lib/dependabot/nuget/update_checker/version_finder.rb b/nuget/lib/dependabot/nuget/update_checker/version_finder.rb index e651f27fc2..769f0d222d 100644 --- a/nuget/lib/dependabot/nuget/update_checker/version_finder.rb +++ b/nuget/lib/dependabot/nuget/update_checker/version_finder.rb @@ -152,7 +152,6 @@ def dependency_details_from_v2_entry(entry) } end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def related_to_current_pre?(version) current_version = dependency.version @@ -176,7 +175,7 @@ def related_to_current_pre?(version) false end end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def v3_nuget_listings diff --git a/nuget/lib/dependabot/nuget/version.rb b/nuget/lib/dependabot/nuget/version.rb index 9000264a42..6c2714469f 100644 --- a/nuget/lib/dependabot/nuget/version.rb +++ b/nuget/lib/dependabot/nuget/version.rb @@ -56,7 +56,6 @@ def compare_release(other) Gem::Version.new(release_str).<=>(Gem::Version.new(other_release_str)) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def compare_prerelease_part(other) release_str = @version_string.split("-").first&.split("+")&.first || "" @@ -80,7 +79,7 @@ def compare_prerelease_part(other) prerelease_string.<=>(other_prerelease_string) end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def compare_build_info(other) diff --git a/python/lib/dependabot/python/file_fetcher.rb b/python/lib/dependabot/python/file_fetcher.rb index ac72756fee..1e107626af 100644 --- a/python/lib/dependabot/python/file_fetcher.rb +++ b/python/lib/dependabot/python/file_fetcher.rb @@ -6,8 +6,6 @@ require "dependabot/file_fetchers/base" require "dependabot/python/requirement_parser" require "dependabot/errors" - -# rubocop:disable Metrics/ClassLength module Dependabot module Python class FileFetcher < Dependabot::FileFetchers::Base @@ -403,6 +401,5 @@ def poetry_path_setup_file_paths end end end -# rubocop:enable Metrics/ClassLength Dependabot::FileFetchers.register("pip", Dependabot::Python::FileFetcher) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index fd3cd9cefc..4f1df25c5d 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -62,8 +62,6 @@ def fetch_updated_dependency_files ] end - # rubocop:disable Metrics/MethodLength - # rubocop:disable Metrics/BlockLength def compile_new_requirement_files SharedHelpers.in_a_temporary_directory do write_updated_dependency_files @@ -106,8 +104,6 @@ def compile_new_requirement_files end.compact end end - # rubocop:enable Metrics/MethodLength - # rubocop:enable Metrics/BlockLength def update_manifest_files dependency_files.map do |file| diff --git a/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb b/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb index cf672bc8ba..07366be523 100644 --- a/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb @@ -13,7 +13,6 @@ module Dependabot module Python class FileUpdater - # rubocop:disable Metrics/ClassLength class PipfileFileUpdater require_relative "pipfile_preparer" require_relative "pipfile_manifest_updater" @@ -461,7 +460,6 @@ def pipenv_env_variables } end end - # rubocop:enable Metrics/ClassLength end end end diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index 8474882d4a..16dad7caf4 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -58,7 +58,6 @@ def resolvable?(version:) private - # rubocop:disable Metrics/MethodLength def fetch_latest_resolvable_version_string(requirement:) @latest_resolvable_version_string ||= {} if @latest_resolvable_version_string.key?(requirement) @@ -97,12 +96,9 @@ def fetch_latest_resolvable_version_string(requirement:) handle_pip_compile_errors(e) end end - # rubocop:enable Metrics/MethodLength - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/MethodLength def handle_pip_compile_errors(error) if error.message.include?("Could not find a version") check_original_requirements_resolvable @@ -146,10 +142,9 @@ def handle_pip_compile_errors(error) raise end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/MethodLength # Needed because pip-compile's resolver isn't perfect. # Note: We raise errors from this method, rather than returning a diff --git a/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb b/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb index 706cc1f585..76410c77c2 100644 --- a/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb @@ -61,7 +61,6 @@ def resolvable?(version:) private - # rubocop:disable Metrics/MethodLength def fetch_latest_resolvable_version_string(requirement:) @latest_resolvable_version_string ||= {} if @latest_resolvable_version_string.key?(requirement) @@ -96,7 +95,6 @@ def fetch_latest_resolvable_version_string(requirement:) end end end - # rubocop:enable Metrics/MethodLength def fetch_version_from_parsed_lockfile(updated_lockfile) version = diff --git a/python/lib/dependabot/python/update_checker/requirements_updater.rb b/python/lib/dependabot/python/update_checker/requirements_updater.rb index 688167248e..b0885a9cf6 100644 --- a/python/lib/dependabot/python/update_checker/requirements_updater.rb +++ b/python/lib/dependabot/python/update_checker/requirements_updater.rb @@ -73,7 +73,6 @@ def updated_pipfile_requirement(req) updated_requirement(req) end - # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity def updated_pyproject_requirement(req) return req unless latest_resolvable_version @@ -99,7 +98,7 @@ def updated_pyproject_requirement(req) rescue UnfixableRequirement req.merge(requirement: :unfixable) end - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity def update_pyproject_version(req) diff --git a/python/lib/dependabot/python/version.rb b/python/lib/dependabot/python/version.rb index 2656bb3985..407b435b31 100644 --- a/python/lib/dependabot/python/version.rb +++ b/python/lib/dependabot/python/version.rb @@ -117,7 +117,7 @@ def normalise_prerelease(version) # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Style/CaseEquality - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength # rubocop:disable Style/ParallelAssignment # rubocop:disable Style/RedundantReturn def old_comp(other) @@ -149,7 +149,7 @@ def old_comp(other) # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Style/CaseEquality - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength # rubocop:enable Style/ParallelAssignment # rubocop:enable Style/RedundantReturn end