From dcb750f2386efe51d4758ef8e9a2210980a6d0c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2020 05:04:59 +0000 Subject: [PATCH 01/16] Update rubocop requirement from ~> 0.88.0 to ~> 0.90.0 in /common Updates the requirements on [rubocop](https://github.com/rubocop-hq/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.88.0...v0.90.0) Signed-off-by: dependabot[bot] --- common/dependabot-common.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/dependabot-common.gemspec b/common/dependabot-common.gemspec index 66db381fca4..51fee28b481 100644 --- a/common/dependabot-common.gemspec +++ b/common/dependabot-common.gemspec @@ -40,7 +40,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", "~> 13" spec.add_development_dependency "rspec", "~> 3.8" spec.add_development_dependency "rspec-its", "~> 1.2" - spec.add_development_dependency "rubocop", "~> 0.88.0" + spec.add_development_dependency "rubocop", "~> 0.90.0" spec.add_development_dependency "vcr", "6.0.0" spec.add_development_dependency "webmock", "~> 3.4" From 0ebc7bae1dccc5a5ef450daa4a3dcab38ad70ce7 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 09:48:15 -0400 Subject: [PATCH 02/16] rubocop-0.90.0 config --- .rubocop.yml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 5ad4c11d0b7..dc131598b1d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -36,6 +36,45 @@ Lint/RaiseException: Lint/StructNewOverride: Enabled: false +Lint/BinaryOperatorWithIdenticalOperands: + Enabled: true + +Lint/DuplicateRequire: + Enabled: true + +Lint/DuplicateRescueException: + Enabled: true + +Lint/EmptyConditionalBody: + Enabled: true + +Lint/EmptyFile: + Enabled: true + +Lint/FloatComparison: + Enabled: true + +Lint/MissingSuper: + Enabled: true + +Lint/OutOfRangeRegexpRef: + Enabled: true + +Lint/SelfAssignment: + Enabled: true + +Lint/TopLevelReturnWithArgument: + Enabled: true + +Lint/TrailingCommaInAttributeDeclaration: + Enabled: true + +Lint/UnreachableLoop: + Enabled: true + +Lint/UselessMethodDefinition: + Enabled: true + Metrics/ClassLength: Max: 350 @@ -45,6 +84,9 @@ Metrics/ModuleLength: Metrics/CyclomaticComplexity: Max: 15 +Metrics/PerceivedComplexity: + Max: 10 # default: 8 + Metrics/AbcSize: Max: 35 @@ -130,3 +172,30 @@ Style/RedundantAssignment: Style/RedundantFileExtensionInRequire: Enabled: false + +Style/CombinableLoops: + Enabled: true + +Style/ExplicitBlockArgument: + Enabled: true + +Style/GlobalStdStream: + Enabled: true + +Style/KeywordParametersOrder: + Enabled: false + +Style/OptionalBooleanParameter: + Enabled: false + +Style/RedundantSelfAssignment: + Enabled: true + +Style/SingleArgumentDig: + Enabled: true + +Style/SoleNestedConditional: + Enabled: true + +Style/StringConcatenation: + Enabled: false From 0785565501dbabfd77ebc92184fea895073bad1f Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:34:59 -0400 Subject: [PATCH 03/16] rubocop-0.90: common --- common/lib/dependabot/file_parsers/base/dependency_set.rb | 3 --- common/lib/dependabot/git_commit_checker.rb | 2 ++ .../lib/dependabot/metadata_finders/base/changelog_finder.rb | 2 ++ .../lib/dependabot/metadata_finders/base/changelog_pruner.rb | 2 -- common/lib/dependabot/pull_request_creator/branch_namer.rb | 2 -- common/lib/dependabot/pull_request_creator/github.rb | 2 ++ common/lib/dependabot/pull_request_creator/labeler.rb | 4 ++++ common/lib/dependabot/pull_request_creator/message_builder.rb | 2 -- .../message_builder/link_and_mention_sanitizer.rb | 2 -- .../lib/dependabot/pull_request_creator/pr_name_prefixer.rb | 2 ++ common/lib/dependabot/shared_helpers.rb | 2 ++ 11 files changed, 14 insertions(+), 11 deletions(-) diff --git a/common/lib/dependabot/file_parsers/base/dependency_set.rb b/common/lib/dependabot/file_parsers/base/dependency_set.rb index 7d87465b206..de2bbad684c 100644 --- a/common/lib/dependabot/file_parsers/base/dependency_set.rb +++ b/common/lib/dependabot/file_parsers/base/dependency_set.rb @@ -60,7 +60,6 @@ def dependency_for_name(name) dependencies.find { |d| d.name&.downcase == name&.downcase } end - # rubocop:disable Metrics/PerceivedComplexity def combined_dependency(old_dep, new_dep) package_manager = old_dep.package_manager v_cls = Utils.version_class_for_package_manager(package_manager) @@ -89,8 +88,6 @@ def combined_dependency(old_dep, new_dep) subdependency_metadata: subdependency_metadata ) end - - # rubocop:enable Metrics/PerceivedComplexity end end end diff --git a/common/lib/dependabot/git_commit_checker.rb b/common/lib/dependabot/git_commit_checker.rb index e284ba923c4..040a97507dd 100644 --- a/common/lib/dependabot/git_commit_checker.rb +++ b/common/lib/dependabot/git_commit_checker.rb @@ -86,6 +86,7 @@ def head_commit_for_current_branch raise Dependabot::GitDependencyReferenceNotFound, dependency.name end + # rubocop:disable Metrics/PerceivedComplexity def local_tag_for_latest_version tags = local_tags. @@ -114,6 +115,7 @@ def local_tag_for_latest_version tag_sha: tag.tag_sha } end + # rubocop:enable Metrics/PerceivedComplexity def git_repo_reachable? local_upload_pack diff --git a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb index ec0a90eafef..e88f10dfce0 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_finder.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_finder.rb @@ -143,6 +143,7 @@ def changelog_from_ref(ref) select_best_changelog(files) end + # rubocop:disable Metrics/PerceivedComplexity def select_best_changelog(files) CHANGELOG_NAMES.each do |name| candidates = files.select { |f| f.name =~ /#{name}/i } @@ -163,6 +164,7 @@ def select_best_changelog(files) nil end + # rubocop:enable Metrics/PerceivedComplexity def tag_for_new_version @tag_for_new_version ||= diff --git a/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb b/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb index 5fda592a42c..1039b2d8f17 100644 --- a/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb +++ b/common/lib/dependabot/metadata_finders/base/changelog_pruner.rb @@ -21,7 +21,6 @@ def includes_previous_version? !old_version_changelog_line.nil? end - # rubocop:disable Metrics/PerceivedComplexity def pruned_text changelog_lines = changelog_text.split("\n") @@ -51,7 +50,6 @@ def pruned_text changelog_lines.slice(slice_range).join("\n").sub(/\n*\z/, "") end - # rubocop:enable Metrics/PerceivedComplexity private diff --git a/common/lib/dependabot/pull_request_creator/branch_namer.rb b/common/lib/dependabot/pull_request_creator/branch_namer.rb index 6e4a2b100d2..142ee205f26 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer.rb @@ -116,7 +116,6 @@ def sanitized_requirement(dependency) gsub(",", "-and-") end - # rubocop:disable Metrics/PerceivedComplexity def new_version(dependency) # Version looks like a git SHA and we could be updating to a specific # ref in which case we return that otherwise we return a shorthand sha @@ -135,7 +134,6 @@ def new_version(dependency) dependency.version end end - # rubocop:enable Metrics/PerceivedComplexity def previous_ref(dependency) previous_refs = dependency.previous_requirements.map do |r| diff --git a/common/lib/dependabot/pull_request_creator/github.rb b/common/lib/dependabot/pull_request_creator/github.rb index 0ed3a9239bf..8ee9f69b12d 100644 --- a/common/lib/dependabot/pull_request_creator/github.rb +++ b/common/lib/dependabot/pull_request_creator/github.rb @@ -51,6 +51,7 @@ def require_up_to_date_base? @require_up_to_date_base end + # rubocop:disable Metrics/PerceivedComplexity def branch_exists?(name) git_metadata_fetcher.ref_names.include?(name) rescue Dependabot::GitDependenciesNotReachable => e @@ -66,6 +67,7 @@ def branch_exists?(name) retrying = true retry end + # rubocop:enable Metrics/PerceivedComplexity def unmerged_pull_request_exists? pull_requests_for_branch.reject(&:merged).any? diff --git a/common/lib/dependabot/pull_request_creator/labeler.rb b/common/lib/dependabot/pull_request_creator/labeler.rb index 7d160dcee8f..b1ab9b8bc56 100644 --- a/common/lib/dependabot/pull_request_creator/labeler.rb +++ b/common/lib/dependabot/pull_request_creator/labeler.rb @@ -113,6 +113,7 @@ def precision end.min end + # rubocop:disable Metrics/PerceivedComplexity def version(dep) return dep.version if version_class.correct?(dep.version) @@ -127,7 +128,9 @@ def version(dep) version_from_ref end + # rubocop:enable Metrics/PerceivedComplexity + # rubocop:disable Metrics/PerceivedComplexity def previous_version(dep) version_str = dep.previous_version return version_str if version_class.correct?(version_str) @@ -144,6 +147,7 @@ def previous_version(dep) version_from_ref end + # rubocop:enable Metrics/PerceivedComplexity def create_default_dependencies_label_if_required return if custom_labels diff --git a/common/lib/dependabot/pull_request_creator/message_builder.rb b/common/lib/dependabot/pull_request_creator/message_builder.rb index eb166c1a11d..cbc079a7b60 100644 --- a/common/lib/dependabot/pull_request_creator/message_builder.rb +++ b/common/lib/dependabot/pull_request_creator/message_builder.rb @@ -567,7 +567,6 @@ def pr_name_prefixer ) end - # rubocop:disable Metrics/PerceivedComplexity def previous_version(dependency) # If we don't have a previous version, we *may* still be able to figure # one out if a ref was provided and has been changed (in which case the @@ -590,7 +589,6 @@ def previous_version(dependency) dependency.previous_version end end - # rubocop:enable Metrics/PerceivedComplexity def new_version(dependency) if dependency.version.match?(/^[0-9a-f]{40}$/) 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 a34223ef1c3..3d29e85093b 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 @@ -58,7 +58,6 @@ def sanitize_mentions(doc) end end - # rubocop:disable Metrics/PerceivedComplexity def sanitize_links(doc) doc.walk do |node| if node.type == :link && node.url.match?(GITHUB_REF_REGEX) @@ -81,7 +80,6 @@ def sanitize_links(doc) end end end - # rubocop:enable Metrics/PerceivedComplexity def replace_github_host(text) text.gsub( 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 614b975f843..62c37c7f28b 100644 --- a/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +++ b/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb @@ -172,6 +172,7 @@ def last_dependabot_commit_prefix last_dependabot_commit_message&.split(/[:(]/)&.first end + # rubocop:disable Metrics/PerceivedComplexity def using_angular_commit_messages? return false if recent_commit_messages.none? @@ -202,6 +203,7 @@ def using_angular_commit_messages? true end + # rubocop:enable Metrics/PerceivedComplexity def using_eslint_commit_messages? return false if recent_commit_messages.none? diff --git a/common/lib/dependabot/shared_helpers.rb b/common/lib/dependabot/shared_helpers.rb index f855c59f5c2..d579222fe1a 100644 --- a/common/lib/dependabot/shared_helpers.rb +++ b/common/lib/dependabot/shared_helpers.rb @@ -178,6 +178,7 @@ def self.configure_git_to_use_https ) end + # rubocop:disable Metrics/PerceivedComplexity 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 @@ -221,6 +222,7 @@ def self.configure_git_credentials(credentials) # Save the file File.write("git.store", git_store_content) end + # rubocop:enable Metrics/PerceivedComplexity def self.reset_git_repo(path) Dir.chdir(path) do From ebe78275fdf49cab5e152fd23a7bdc26bd5c21c8 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:42:07 -0400 Subject: [PATCH 04/16] rubocop-0.90: bundler reconsider `MissingSuper`, as there are plenty of hits in the first extension module we encountered. --- .rubocop.yml | 2 +- bundler/lib/dependabot/bundler/file_updater.rb | 2 ++ .../lib/dependabot/bundler/file_updater/lockfile_updater.rb | 4 ++++ .../lib/dependabot/bundler/update_checker/file_preparer.rb | 4 ++++ .../dependabot/bundler/update_checker/requirements_updater.rb | 3 --- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index dc131598b1d..1b522f79a60 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -55,7 +55,7 @@ Lint/FloatComparison: Enabled: true Lint/MissingSuper: - Enabled: true + Enabled: false Lint/OutOfRangeRegexpRef: Enabled: true diff --git a/bundler/lib/dependabot/bundler/file_updater.rb b/bundler/lib/dependabot/bundler/file_updater.rb index 516e5bad811..aadef1ab781 100644 --- a/bundler/lib/dependabot/bundler/file_updater.rb +++ b/bundler/lib/dependabot/bundler/file_updater.rb @@ -20,6 +20,7 @@ def self.updated_files_regex ] end + # rubocop:disable Metrics/PerceivedComplexity def updated_dependency_files updated_files = [] @@ -59,6 +60,7 @@ def updated_dependency_files updated_files end + # rubocop:enable Metrics/PerceivedComplexity private diff --git a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb index 78429d6a0e9..933c028e71b 100644 --- a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb +++ b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb @@ -240,6 +240,7 @@ def unlock_yanked_gem(dependencies_to_unlock, error) dependencies_to_unlock << gem_name end + # rubocop:disable Metrics/PerceivedComplexity def unlock_blocking_subdeps(dependencies_to_unlock, error) all_deps = ::Bundler::LockfileParser.new(sanitized_lockfile_body). specs.map(&:name).map(&:to_s) @@ -268,6 +269,7 @@ def unlock_blocking_subdeps(dependencies_to_unlock, error) # information to chart the full path through all conflicts unwound dependencies_to_unlock.append(*allowed_new_unlocks) end + # rubocop:enable Metrics/PerceivedComplexity def build_definition(dependencies_to_unlock) defn = ::Bundler::Definition.build( @@ -407,6 +409,7 @@ def sanitized_gemspec_content(gemspec_content) rewrite(gemspec_content) end + # rubocop:disable Metrics/PerceivedComplexity def replacement_version_for_gemspec(gemspec_content) return "0.0.1" unless lockfile @@ -423,6 +426,7 @@ def replacement_version_for_gemspec(gemspec_content) spec = gemspec_specs.find { |s| s.name == gem_name } spec&.version || gemspec_specs.first&.version || "0.0.1" end + # rubocop:enable Metrics/PerceivedComplexity def relevant_credentials credentials. diff --git a/bundler/lib/dependabot/bundler/update_checker/file_preparer.rb b/bundler/lib/dependabot/bundler/update_checker/file_preparer.rb index fc515815daa..b5c9c11fe9d 100644 --- a/bundler/lib/dependabot/bundler/update_checker/file_preparer.rb +++ b/bundler/lib/dependabot/bundler/update_checker/file_preparer.rb @@ -214,6 +214,7 @@ def updated_version_requirement_string(filename) lower_bound_req + ", <= #{latest_allowable_version}" end + # rubocop:disable Metrics/PerceivedComplexity def updated_version_req_lower_bound(filename) original_req = dependency.requirements. find { |r| r.fetch(:file) == filename }&. @@ -234,6 +235,7 @@ def updated_version_req_lower_bound(filename) ">= #{version_for_requirement || 0}" end end + # rubocop:enable Metrics/PerceivedComplexity def remove_git_source(content) FileUpdater::GitSourceRemover.new( @@ -261,6 +263,7 @@ def lock_ruby_version?(file) @lock_ruby_version && file == gemfile end + # rubocop:disable Metrics/PerceivedComplexity def replacement_version_for_gemspec(gemspec_content) return "0.0.1" unless lockfile @@ -278,6 +281,7 @@ def replacement_version_for_gemspec(gemspec_content) spec = gemspec_specs.find { |s| s.name == gem_name } spec&.version || gemspec_specs.first&.version || "0.0.1" end + # rubocop:enable Metrics/PerceivedComplexity def sanitized_lockfile_content re = FileUpdater::LockfileUpdater::LOCKFILE_ENDING diff --git a/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb b/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb index a7cd7bdd1c0..c7377843c99 100644 --- a/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb +++ b/bundler/lib/dependabot/bundler/update_checker/requirements_updater.rb @@ -252,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/PerceivedComplexity def update_greatest_version(requirement, version_to_be_permitted) if version_to_be_permitted.is_a?(String) version_to_be_permitted = Gem::Version.new(version_to_be_permitted) @@ -278,8 +277,6 @@ def update_greatest_version(requirement, version_to_be_permitted) Gem::Requirement.new("#{op} #{new_segments.join('.')}") end - - # rubocop:enable Metrics/PerceivedComplexity end end end From 27067c0615a82ee48148efb25b980beb6df89901 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:51:19 -0400 Subject: [PATCH 05/16] rubocop-0.90: cargo --- cargo/lib/dependabot/cargo/file_fetcher.rb | 5 +++-- cargo/lib/dependabot/cargo/file_parser.rb | 2 ++ cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb | 2 ++ cargo/lib/dependabot/cargo/requirement.rb | 2 -- cargo/lib/dependabot/cargo/update_checker/file_preparer.rb | 2 ++ .../lib/dependabot/cargo/update_checker/version_resolver.rb | 2 ++ 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cargo/lib/dependabot/cargo/file_fetcher.rb b/cargo/lib/dependabot/cargo/file_fetcher.rb index 3b6c0366faf..2e52d7698c4 100644 --- a/cargo/lib/dependabot/cargo/file_fetcher.rb +++ b/cargo/lib/dependabot/cargo/file_fetcher.rb @@ -218,6 +218,7 @@ def workspace_dependency_paths_from_file(file) # an alternative source (i.e., a git source) is also specified # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize def required_path?(file, path) # Paths specified in dependency declaration Cargo::FileParser::DEPENDENCY_TYPES.each do |type| @@ -254,9 +255,9 @@ def required_path?(file, path) false end - - # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/PerceivedComplexity + # rubocop:enable Metrics/CyclomaticComplexity def expand_workspaces(path) path = Pathname.new(path).cleanpath.to_path diff --git a/cargo/lib/dependabot/cargo/file_parser.rb b/cargo/lib/dependabot/cargo/file_parser.rb index 6e49c119c01..e1f994f3d9e 100644 --- a/cargo/lib/dependabot/cargo/file_parser.rb +++ b/cargo/lib/dependabot/cargo/file_parser.rb @@ -56,6 +56,7 @@ def check_rust_workspace_root raise Dependabot::DependencyFileNotEvaluatable, msg end + # rubocop:disable Metrics/PerceivedComplexity def manifest_dependencies dependency_set = DependencySet.new @@ -82,6 +83,7 @@ def manifest_dependencies dependency_set end + # rubocop:enable Metrics/PerceivedComplexity def build_dependency(name, requirement, type, file) Dependency.new( diff --git a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb index 01c93a59be2..4bb102534e1 100644 --- a/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb +++ b/cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb @@ -68,6 +68,7 @@ def handle_cargo_error(error) # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/AbcSize def better_specification_needed?(error) return false if @custom_specification return false unless error.message.match?(/specification .* is ambigu/) @@ -96,6 +97,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 diff --git a/cargo/lib/dependabot/cargo/requirement.rb b/cargo/lib/dependabot/cargo/requirement.rb index e960196cb63..1e176d3989b 100644 --- a/cargo/lib/dependabot/cargo/requirement.rb +++ b/cargo/lib/dependabot/cargo/requirement.rb @@ -53,8 +53,6 @@ def initialize(*requirements) private def convert_rust_constraint_to_ruby_constraint(req_string) - req_string = req_string - if req_string.include?("*") ruby_range(req_string.gsub(/(?:\.|^)[*]/, "").gsub(/^[^\d]/, "")) elsif req_string.match?(/^~[^>]/) then convert_tilde_req(req_string) diff --git a/cargo/lib/dependabot/cargo/update_checker/file_preparer.rb b/cargo/lib/dependabot/cargo/update_checker/file_preparer.rb index d78c9828304..aa484eb5a00 100644 --- a/cargo/lib/dependabot/cargo/update_checker/file_preparer.rb +++ b/cargo/lib/dependabot/cargo/update_checker/file_preparer.rb @@ -201,6 +201,7 @@ def temporary_requirement_for_resolution(filename) lower_bound_req + ", <= #{latest_allowable_version}" end + # rubocop:disable Metrics/PerceivedComplexity def lower_bound_version @lower_bound_version ||= if git_dependency? && git_dependency_version @@ -220,6 +221,7 @@ def lower_bound_version version_from_requirement || 0 end end + # rubocop:enable Metrics/PerceivedComplexity def git_dependency_version return unless lockfile diff --git a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb index b74c1bb6220..0d028e2dc5e 100644 --- a/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb +++ b/cargo/lib/dependabot/cargo/update_checker/version_resolver.rb @@ -80,6 +80,7 @@ def fetch_version_from_new_lockfile # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/AbcSize def better_specification_needed?(error) return false if @custom_specification return false unless error.message.match?(/specification .* is ambigu/) @@ -108,6 +109,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 From 4154b712692ac8ba11d6bbb5788a95e9e277080f Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:54:38 -0400 Subject: [PATCH 06/16] rubocop-0.90: composer --- composer/lib/dependabot/composer/requirement.rb | 4 ---- .../composer/update_checker/requirements_updater.rb | 2 ++ .../dependabot/composer/update_checker/version_resolver.rb | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer/lib/dependabot/composer/requirement.rb b/composer/lib/dependabot/composer/requirement.rb index 021528c6e30..6d25a5d3ab1 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/PerceivedComplexity def convert_php_constraint_to_ruby_constraint(req_string) req_string = req_string.strip.gsub(/v(?=\d)/, "").gsub(/\.$/, "") @@ -53,8 +52,6 @@ def convert_php_constraint_to_ruby_constraint(req_string) end end - # rubocop:enable Metrics/PerceivedComplexity - def convert_wildcard_req(req_string) if req_string.start_with?(">", "<") msg = "Illformed requirement [#{req_string.inspect}]" @@ -87,7 +84,6 @@ def convert_caret_req(req_string) end def convert_hyphen_req(req_string) - req_string = req_string lower_bound, upper_bound = req_string.split(/\s+-\s+/) if upper_bound.split(".").count < 3 upper_bound_parts = upper_bound.split(".") diff --git a/composer/lib/dependabot/composer/update_checker/requirements_updater.rb b/composer/lib/dependabot/composer/update_checker/requirements_updater.rb index 0f3d96bc6ce..7baf4b23789 100644 --- a/composer/lib/dependabot/composer/update_checker/requirements_updater.rb +++ b/composer/lib/dependabot/composer/update_checker/requirements_updater.rb @@ -96,6 +96,7 @@ def updated_alias(req) req.merge(requirement: new_req) end + # rubocop:disable Metrics/PerceivedComplexity def widen_requirement(req, or_separator) current_requirement = req[:requirement] reqs = current_requirement.strip.split(SEPARATOR).map(&:strip) @@ -115,6 +116,7 @@ def widen_requirement(req, or_separator) req.merge(requirement: updated_requirement) end + # rubocop:enable Metrics/PerceivedComplexity def update_requirement_version(req, or_separator) current_requirement = 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 069e4a67e9d..790822c33b5 100644 --- a/composer/lib/dependabot/composer/update_checker/version_resolver.rb +++ b/composer/lib/dependabot/composer/update_checker/version_resolver.rb @@ -193,6 +193,7 @@ def lock_git_dependencies(content) end # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize def updated_version_requirement_string lower_bound = if requirements_to_unlock == :none @@ -228,7 +229,7 @@ def updated_version_requirement_string lower_bound + ", <= #{latest_allowable_version}" end - + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/PerceivedComplexity # rubocop:disable Metrics/PerceivedComplexity From aeb8408aff3c0fbbfd3d8c305efb49a49226a874 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:57:27 -0400 Subject: [PATCH 07/16] rubocop-0.90: dep --- dep/lib/dependabot/dep/path_converter.rb | 2 ++ dep/lib/dependabot/dep/requirement.rb | 1 - dep/lib/dependabot/dep/update_checker.rb | 3 --- dep/lib/dependabot/dep/update_checker/file_preparer.rb | 2 ++ 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dep/lib/dependabot/dep/path_converter.rb b/dep/lib/dependabot/dep/path_converter.rb index cc61ebb76e5..cf86aa00768 100644 --- a/dep/lib/dependabot/dep/path_converter.rb +++ b/dep/lib/dependabot/dep/path_converter.rb @@ -21,6 +21,7 @@ def self.git_url_for_path(path) ) end + # rubocop:disable Metrics/PerceivedComplexity # Used in dependabot-backend, which doesn't have access to any Go # helpers. # TODO: remove the need for this. @@ -52,6 +53,7 @@ def self.git_url_for_path_without_go_helper(path) import_details[2] end + # rubocop:enable Metrics/PerceivedComplexity def self.fetch_path_metadata(path) # TODO: This is not robust! Instead, we should shell out to Go and diff --git a/dep/lib/dependabot/dep/requirement.rb b/dep/lib/dependabot/dep/requirement.rb index 7aa811b6b17..5170fd6e21e 100644 --- a/dep/lib/dependabot/dep/requirement.rb +++ b/dep/lib/dependabot/dep/requirement.rb @@ -60,7 +60,6 @@ def initialize(*requirements) private def convert_go_constraint_to_ruby_constraint(req_string) - req_string = req_string req_string = convert_wildcard_characters(req_string) if req_string.match?(WILDCARD_REGEX) diff --git a/dep/lib/dependabot/dep/update_checker.rb b/dep/lib/dependabot/dep/update_checker.rb index 903e7691594..47c72a2b88d 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/PerceivedComplexity def latest_resolvable_version_for_git_dependency return latest_version if modules_dependency? @@ -127,8 +126,6 @@ def latest_resolvable_version_for_git_dependency nil end - # rubocop:enable Metrics/PerceivedComplexity - def version_from_tag(tag) # To compare with the current version we either use the commit SHA # (if that's what the parser picked up) of the tag name. diff --git a/dep/lib/dependabot/dep/update_checker/file_preparer.rb b/dep/lib/dependabot/dep/update_checker/file_preparer.rb index bfba6c3835d..70dcbd3388c 100644 --- a/dep/lib/dependabot/dep/update_checker/file_preparer.rb +++ b/dep/lib/dependabot/dep/update_checker/file_preparer.rb @@ -168,6 +168,7 @@ def temporary_requirement_for_resolution(filename) lower_bound_req + ", <= #{latest_allowable_version}" end + # rubocop:disable Metrics/PerceivedComplexity def lower_bound_version @lower_bound_version ||= if version_from_lockfile @@ -185,6 +186,7 @@ def lower_bound_version version_from_requirement || 0 end end + # rubocop:enable Metrics/PerceivedComplexity def version_from_lockfile return unless lockfile From 636047d66c7ff9577ba6f4822b140caff0bacd88 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 13:58:45 -0400 Subject: [PATCH 08/16] rubocop-0.90: github_actions --- github_actions/lib/dependabot/github_actions/update_checker.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/github_actions/lib/dependabot/github_actions/update_checker.rb b/github_actions/lib/dependabot/github_actions/update_checker.rb index 93945f0d7f9..52cfcd898de 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/PerceivedComplexity def updated_source # TODO: Support Docker sources return dependency_source_details unless git_dependency? @@ -101,8 +100,6 @@ def updated_source dependency_source_details end - # rubocop:enable Metrics/PerceivedComplexity - def dependency_source_details sources = dependency.requirements.map { |r| r.fetch(:source) }.uniq.compact From 802b339bfd968194d2363eace034455bb64130f2 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:01:10 -0400 Subject: [PATCH 09/16] rubocop-0.90: go_modules --- go_modules/lib/dependabot/go_modules/path_converter.rb | 2 ++ go_modules/lib/dependabot/go_modules/requirement.rb | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/go_modules/lib/dependabot/go_modules/path_converter.rb b/go_modules/lib/dependabot/go_modules/path_converter.rb index 264640d6a72..b0e0f3ff546 100644 --- a/go_modules/lib/dependabot/go_modules/path_converter.rb +++ b/go_modules/lib/dependabot/go_modules/path_converter.rb @@ -21,6 +21,7 @@ def self.git_url_for_path(path) ) end + # rubocop:disable Metrics/PerceivedComplexity # Used in dependabot-backend, which doesn't have access to any Go # helpers. # TODO: remove the need for this. @@ -52,6 +53,7 @@ def self.git_url_for_path_without_go_helper(path) import_details[2] end + # rubocop:enable Metrics/PerceivedComplexity def self.fetch_path_metadata(path) # TODO: This is not robust! Instead, we should shell out to Go and diff --git a/go_modules/lib/dependabot/go_modules/requirement.rb b/go_modules/lib/dependabot/go_modules/requirement.rb index b6fad4ea83d..d30d1460d85 100644 --- a/go_modules/lib/dependabot/go_modules/requirement.rb +++ b/go_modules/lib/dependabot/go_modules/requirement.rb @@ -60,7 +60,6 @@ def initialize(*requirements) private def convert_go_constraint_to_ruby_constraint(req_string) - req_string = req_string req_string = convert_wildcard_characters(req_string) if req_string.match?(WILDCARD_REGEX) From 5ee85654fd0d76ada49111a9498732d65e94dd02 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:03:07 -0400 Subject: [PATCH 10/16] rubocop-0.90: hex --- hex/lib/dependabot/hex/update_checker.rb | 2 ++ hex/lib/dependabot/hex/update_checker/requirements_updater.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hex/lib/dependabot/hex/update_checker.rb b/hex/lib/dependabot/hex/update_checker.rb index cde62694c41..30eefa7fb5c 100644 --- a/hex/lib/dependabot/hex/update_checker.rb +++ b/hex/lib/dependabot/hex/update_checker.rb @@ -209,6 +209,7 @@ def prepared_dependency_files(unlock_requirement:, ).prepared_dependency_files end + # rubocop:disable Metrics/PerceivedComplexity def latest_release_from_hex_registry @latest_release_from_hex_registry ||= begin @@ -231,6 +232,7 @@ def latest_release_from_hex_registry filtered.max end end + # rubocop:enable Metrics/PerceivedComplexity def hex_registry_response return @hex_registry_response if @hex_registry_requested diff --git a/hex/lib/dependabot/hex/update_checker/requirements_updater.rb b/hex/lib/dependabot/hex/update_checker/requirements_updater.rb index 6085a839b7f..10d7ac26836 100644 --- a/hex/lib/dependabot/hex/update_checker/requirements_updater.rb +++ b/hex/lib/dependabot/hex/update_checker/requirements_updater.rb @@ -33,6 +33,7 @@ def updated_requirements attr_reader :requirements, :latest_resolvable_version, :updated_source # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize def updated_mixfile_requirement(req) req = update_source(req) return req unless latest_resolvable_version && req[:requirement] @@ -59,7 +60,7 @@ def updated_mixfile_requirement(req) req.merge(requirement: new_requirement) end - + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/PerceivedComplexity def update_source(requirement_hash) From 88eb9c8c6a6085029a75e429d09e93f5dd937f3c Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:04:44 -0400 Subject: [PATCH 11/16] rubocop-0.90: maven --- maven/lib/dependabot/maven/file_parser/property_value_finder.rb | 2 ++ maven/lib/dependabot/maven/file_parser/repositories_finder.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/maven/lib/dependabot/maven/file_parser/property_value_finder.rb b/maven/lib/dependabot/maven/file_parser/property_value_finder.rb index ba1c60af3b6..4eabd52ffab 100644 --- a/maven/lib/dependabot/maven/file_parser/property_value_finder.rb +++ b/maven/lib/dependabot/maven/file_parser/property_value_finder.rb @@ -86,6 +86,7 @@ def sanitize_property_name(property_name) property_name.sub(/^pom\./, "").sub(/^project\./, "") end + # rubocop:disable Metrics/PerceivedComplexity def parent_pom(pom) doc = Nokogiri::XML(pom.content) doc.remove_namespaces! @@ -106,6 +107,7 @@ def parent_pom(pom) fetch_remote_parent_pom(group_id, artifact_id, version, pom) end + # rubocop:enable Metrics/PerceivedComplexity def parent_repository_urls(pom) repositories_finder.repository_urls( diff --git a/maven/lib/dependabot/maven/file_parser/repositories_finder.rb b/maven/lib/dependabot/maven/file_parser/repositories_finder.rb index 756fa91f0a2..44269f48467 100644 --- a/maven/lib/dependabot/maven/file_parser/repositories_finder.rb +++ b/maven/lib/dependabot/maven/file_parser/repositories_finder.rb @@ -61,6 +61,7 @@ def evaluate_properties? @evaluate_properties end + # rubocop:disable Metrics/PerceivedComplexity def parent_pom(pom, repo_urls) doc = Nokogiri::XML(pom.content) doc.remove_namespaces! @@ -81,6 +82,7 @@ def parent_pom(pom, repo_urls) fetch_remote_parent_pom(group_id, artifact_id, version, repo_urls) end + # rubocop:enable Metrics/PerceivedComplexity def internal_dependency_poms return @internal_dependency_poms if @internal_dependency_poms From e03323a065dca8a13a629608f3dc68181b8be845 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:17:25 -0400 Subject: [PATCH 12/16] rubocop-0.90: npm_and_yarn --- .rubocop.yml | 2 +- .../dependabot/npm_and_yarn/file_fetcher.rb | 5 ++-- .../file_updater/npmrc_builder.rb | 4 +-- .../file_updater/yarn_lockfile_updater.rb | 2 +- .../dependabot/npm_and_yarn/requirement.rb | 6 +---- .../update_checker/latest_version_finder.rb | 2 ++ .../subdependency_version_resolver.rb | 3 --- .../update_checker/version_resolver.rb | 2 ++ .../path_dependency_builder_spec.rb | 6 ++--- .../npm_and_yarn/file_fetcher_spec.rb | 4 +-- .../npm_and_yarn/file_parser_spec.rb | 1 - .../file_updater/package_json_updater_spec.rb | 14 +++++----- .../npm_and_yarn/file_updater_spec.rb | 26 +++++++++---------- .../npm_and_yarn/metadata_finder_spec.rb | 8 +++--- .../latest_version_finder_spec.rb | 14 +++++----- 15 files changed, 47 insertions(+), 52 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1b522f79a60..1603412d875 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -97,7 +97,7 @@ Metrics/BlockLength: Max: 35 Exclude: - '*/Rakefile' - - '*/spec/**/*' + - '**/spec/**/*' - '*/dependabot-*.gemspec' Metrics/ParameterLists: 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 d0e7c91e66b..ef4d4928b70 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 @@ -31,7 +31,6 @@ def self.required_files_message private - # rubocop:disable Metrics/PerceivedComplexity def fetch_files fetched_files = [] fetched_files << package_json @@ -48,8 +47,6 @@ def fetch_files fetched_files.uniq end - # rubocop:enable Metrics/PerceivedComplexity - def package_json @package_json ||= fetch_file_from_host("package.json") end @@ -173,6 +170,7 @@ def path_dependency_details(fetched_files) ].uniq end + # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/AbcSize def path_dependency_details_from_manifest(file) return [] unless file.name.end_with?("package.json") @@ -208,6 +206,7 @@ def path_dependency_details_from_manifest(file) raise Dependabot::DependencyFileNotParseable, file.path end # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/PerceivedComplexity def path_dependency_details_from_npm_lockfile(parsed_lockfile) path_starts = NPM_PATH_DEPENDENCY_STARTS diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb index 07a988b4b74..1941644a496 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb @@ -127,7 +127,6 @@ def build_npmrc_from_yarnrc build_npmrc_content_from_lockfile end - # rubocop:disable Metrics/PerceivedComplexity def credential_lines_for_npmrc lines = [] registry_credentials.each do |cred| @@ -154,8 +153,8 @@ def credential_lines_for_npmrc # Work around a suspected yarn bug ["always-auth = true"] + lines end - # rubocop:enable Metrics/PerceivedComplexity + # rubocop:disable Metrics/PerceivedComplexity def registry_scopes(registry) # Central registries don't just apply to scopes return if CENTRAL_REGISTRIES.include?(registry) @@ -182,6 +181,7 @@ def registry_scopes(registry) scopes.map { |scope| "@#{scope}:registry=https://#{registry}" } end + # rubocop:enable Metrics/PerceivedComplexity def registry_credentials credentials.select { |cred| cred.fetch("type") == "npm_registry" } 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 b872726339e..8a8f0937490 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 @@ -171,7 +171,7 @@ def handle_yarn_lock_updater_error(error, yarn_lock) # Local path error: When installing a git dependency which # is using local file paths for sub-dependencies (e.g. unbuilt yarn # workspace project) - sub_dep_local_path_err = "Package \"\" refers to a non-existing file" + sub_dep_local_path_err = 'Package "" refers to a non-existing file' if error_message.match?(INVALID_PACKAGE) || error_message.start_with?(sub_dep_local_path_err) raise_resolvability_error(error_message, yarn_lock) 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 3a6d164cad8..f5e86307ea9 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/requirement.rb @@ -56,7 +56,6 @@ def initialize(*requirements) private - # rubocop:disable Metrics/PerceivedComplexity def convert_js_constraint_to_ruby_constraint(req_string) return req_string if req_string.match?(/^([A-Za-uw-z]|v[^\d])/) @@ -72,7 +71,6 @@ def convert_js_constraint_to_ruby_constraint(req_string) else ruby_range(req_string) end end - # rubocop:enable Metrics/PerceivedComplexity def convert_tilde_req(req_string) version = req_string.gsub(/^~\>?[\s=]*/, "") @@ -112,11 +110,10 @@ def ruby_range(req_string) "~> #{parts.join('.')}" end - # rubocop:disable Metrics/PerceivedComplexity def convert_caret_req(req_string) version = req_string.gsub(/^\^[\s=]*/, "") parts = version.split(".") - parts = parts.fill("x", parts.length...3) + parts.fill("x", parts.length...3) first_non_zero = parts.find { |d| d != "0" } first_non_zero_index = first_non_zero ? parts.index(first_non_zero) : parts.count - 1 @@ -133,7 +130,6 @@ def convert_caret_req(req_string) [">= #{version}", "< #{upper_bound}"] end - # rubocop:enable Metrics/PerceivedComplexity end end end 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 965f2a7bae4..249d1881389 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 @@ -167,6 +167,7 @@ def version_from_dist_tags wants_latest_dist_tag?(latest) ? latest : nil end + # rubocop:disable Metrics/PerceivedComplexity def related_to_current_pre?(version) current_version = dependency.version if current_version && @@ -188,6 +189,7 @@ def related_to_current_pre?(version) false end end + # rubocop:enable Metrics/PerceivedComplexity def specified_dist_tag_requirement? dependency.requirements.any? do |req| 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 f6636d18e09..f52f5e852df 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/PerceivedComplexity def run_yarn_updater(path, lockfile_name) SharedHelpers.with_git_configured(credentials: credentials) do Dir.chdir(path) do @@ -107,8 +106,6 @@ def run_yarn_updater(path, lockfile_name) sleep(rand(3.0..10.0)) && retry end - # rubocop:enable Metrics/PerceivedComplexity - def run_npm_updater(path, lockfile_name) SharedHelpers.with_git_configured(credentials: credentials) do Dir.chdir(path) do 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 bd79a21b1f4..a1631e54757 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 @@ -130,6 +130,7 @@ def latest_version_finder(dep) ) end + # rubocop:disable Metrics/PerceivedComplexity def resolve_latest_previous_version(dep, updated_version) return dep.version if dep.version @@ -160,6 +161,7 @@ def resolve_latest_previous_version(dep, updated_version) latest_previous_version end end + # rubocop:enable Metrics/PerceivedComplexity def part_of_tightly_locked_monorepo? monorepo_dep_names = diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder_spec.rb index d9f0cab3fe2..c273c813ef0 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder_spec.rb @@ -49,7 +49,7 @@ expect(dependency_file.name).to eq("deps/etag/package.json") expect(dependency_file.support_file?).to eq(true) expect(dependency_file.content). - to eq("{\"name\":\"etag\",\"version\":\"0.0.1\"}") + to eq('{"name":"etag","version":"0.0.1"}') end end @@ -91,7 +91,7 @@ expect(dependency_file.name).to eq("deps/etag/package.json") expect(dependency_file.support_file?).to eq(true) expect(dependency_file.content). - to eq("{\"name\":\"etag\",\"version\":\"1.8.0\"}") + to eq('{"name":"etag","version":"1.8.0"}') end end @@ -143,7 +143,7 @@ expect(dependency_file.name).to eq("deps/etag/package.json") expect(dependency_file.support_file?).to eq(true) expect(dependency_file.content). - to eq("{\"name\":\"etag\",\"version\":\"1.8.0\"}") + to eq('{"name":"etag","version":"1.8.0"}') end end end diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb index 77d44a38b78..67a1caca5a6 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb @@ -505,7 +505,7 @@ find { |f| f.name == "deps/etag/package.json" } expect(path_file.support_file?).to eq(true) expect(path_file.content). - to eq("{\"name\":\"etag\",\"version\":\"0.0.1\"}") + to eq('{"name":"etag","version":"0.0.1"}') end end @@ -634,7 +634,7 @@ find { |f| f.name == "mocks/sprintf-js/package.json" } expect(path_file.support_file?).to eq(true) expect(path_file.content). - to eq("{\"name\":\"sprintf-js\",\"version\":\"0.0.0\"}") + to eq('{"name":"sprintf-js","version":"0.0.0"}') end end end diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb index f54a6045795..60d0bf1d9c8 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb @@ -3,7 +3,6 @@ require "spec_helper" require "dependabot/source" require "dependabot/dependency_file" -require "dependabot/source" require "dependabot/npm_and_yarn/file_parser" require_common_spec "file_parsers/shared_examples_for_file_parsers" diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/package_json_updater_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/package_json_updater_spec.rb index 4deed0952f3..f82229bb27f 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/package_json_updater_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater/package_json_updater_spec.rb @@ -45,8 +45,8 @@ subject(:updated_package_json) { package_json_updater.updated_package_json } its(:content) { is_expected.to include "{{ name }}" } - its(:content) { is_expected.to include "\"fetch-factory\": \"^0.0.2\"" } - its(:content) { is_expected.to include "\"etag\" : \"^1.0.0\"" } + its(:content) { is_expected.to include '"fetch-factory": "^0.0.2"' } + its(:content) { is_expected.to include '"etag" : "^1.0.0"' } context "when the minor version is specified" do let(:dependency) do @@ -70,7 +70,7 @@ end let(:manifest_fixture_name) { "minor_version_specified.json" } - its(:content) { is_expected.to include "\"fetch-factory\": \"0.2.x\"" } + its(:content) { is_expected.to include '"fetch-factory": "0.2.x"' } end context "when the requirement hasn't changed" do @@ -388,14 +388,14 @@ end its(:content) do - is_expected.to include("\"jonschlinkert/is-number#semver:^4.0.0\"") + is_expected.to include('"jonschlinkert/is-number#semver:^4.0.0"') end context "without the `semver:` marker" do let(:manifest_fixture_name) { "github_dependency_yarn_semver.json" } its(:content) do - is_expected.to include("\"jonschlinkert/is-number#^4.0.0\"") + is_expected.to include('"jonschlinkert/is-number#^4.0.0"') end end end @@ -423,9 +423,9 @@ ) end - its(:content) { is_expected.to include "\"lodash\": \"^1.3.1\"" } + its(:content) { is_expected.to include '"lodash": "^1.3.1"' } its(:content) do - is_expected.to include "\"etag\": \"file:./deps/etag\"" + is_expected.to include '"etag": "file:./deps/etag"' end end diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb index c2ba8a0f436..250d4eb9d29 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb @@ -643,7 +643,7 @@ "5fbc24ccc37bd72052ce71ceae5b4934feb3ac19") expect(updated_yarn_lock.content). - to include("gitlab:kornelski/babel-preset-php#master\":") + to include('gitlab:kornelski/babel-preset-php#master":') expect(updated_yarn_lock.content).to include( "https://gitlab.com/kornelski/babel-preset-php/repository/archive.tar.gz?ref=5fbc24ccc37bd72052ce71ceae5b4934feb3ac19" ) @@ -662,7 +662,7 @@ "0c6b15a88bc10cd47f67a09506399dfc9ddc075d") expect(updated_yarn_lock.content). - to include("is-number@github:jonschlinkert/is-number#master\":") + to include('is-number@github:jonschlinkert/is-number#master":') expect(updated_yarn_lock.content).to include( "https://codeload.github.com/jonschlinkert/is-number/tar.gz/0c6b15a88bc10cd47f67a09506399dfc9ddc075d" ) @@ -711,7 +711,7 @@ "0c6b15a88bc10cd47f67a09506399dfc9ddc075d") expect(updated_yarn_lock.content). - to include("\"is-number@jonschlinkert/is-number#semver:^4.0.0\":") + to include('"is-number@jonschlinkert/is-number#semver:^4.0.0":') expect(updated_yarn_lock.content). to include("0c6b15a88bc10cd47f67a09506399dfc9ddc075d") end @@ -840,8 +840,8 @@ "1c62524db6e156050552fa4938c2de363d3116df") expect(updated_yarn_lock.content).to include( - "\"@reach/router@reach/router"\ - "#1c62524db6e156050552fa4938c2de363d3116df\":" + '"@reach/router@reach/router'\ + '#1c62524db6e156050552fa4938c2de363d3116df":' ) expect(updated_yarn_lock.content).to include( "https://codeload.github.com/reach/router/tar.gz/"\ @@ -892,7 +892,7 @@ "0c6b15a88bc10cd47f67a09506399dfc9ddc075d") expect(updated_yarn_lock.content). - to include("is-number@github:jonschlinkert/is-number#4.0.0\":") + to include('is-number@github:jonschlinkert/is-number#4.0.0":') expect(updated_yarn_lock.content).to include( "https://codeload.github.com/jonschlinkert/is-number/tar.gz/0c6b15a88bc10cd47f67a09506399dfc9ddc075d" ) @@ -1051,9 +1051,9 @@ expect(updated_yarn_lock.content).to include("lodash@^1.3.1") expect(updated_package_json.content). - to include("\"lodash\": \"^1.3.1\"") + to include('"lodash": "^1.3.1"') expect(updated_package_json.content). - to include("\"etag\": \"file:./deps/etag\"") + to include('"etag": "file:./deps/etag"') end end @@ -1406,7 +1406,7 @@ expect(updated_files.map(&:name)).to match_array(["yarn.lock"]) expect(updated_yarn_lock.content). to include("js-yaml@^3.10.0, js-yaml@^3.4.6, js-yaml@^3.9.0:\n"\ - " version \"3.12.0\"") + ' version "3.12.0"') end end @@ -2743,10 +2743,10 @@ expect(lockfile.content).to_not include("lodash@^1.2.1:") expect(lockfile.content).to_not include("workspace-aggregator") - expect(package.content).to include("\"lodash\": \"1.3.1\"") + expect(package.content).to include('"lodash": "1.3.1"') expect(package.content).to include("\"./packages/*\",\n") - expect(package1.content).to include("\"lodash\": \"^1.3.1\"") - expect(other_package.content).to include("\"lodash\": \"^1.3.1\"") + expect(package1.content).to include('"lodash": "^1.3.1"') + expect(other_package.content).to include('"lodash": "^1.3.1"') end context "with a dependency that doesn't appear in all the workspaces" do @@ -2872,7 +2872,7 @@ # version expect(updated_yarn_lock.content).to include( "graphql@0.11.7, "\ - "\"graphql@git://github.com/graphql/graphql-js.git#npm\":" + '"graphql@git://github.com/graphql/graphql-js.git#npm":' ) expect(updated_yarn_lock.content). to include("241058716a075a04fd6a84cd76151cd94c3ffd3a") diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb index 3211697ab42..abea384365c 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb @@ -213,7 +213,7 @@ context "that is private" do before do stub_request(:get, "https://registry.npmjs.org/@etag%2Fetag"). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://registry.npmjs.org/@etag%2Fetag"). with(headers: { "Authorization" => "Bearer secret_token" }). to_return(status: 200, body: npm_all_versions_response) @@ -254,13 +254,13 @@ before do body = fixture("gemfury_response_etag.json") stub_request(:get, "https://npm.fury.io/dependabot/@etag%2Fetag"). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request( :get, "https://npm.fury.io/dependabot/@etag%2Fetag/latest" - ).to_return(status: 404, body: "{\"error\":\"Not found\"}") + ).to_return(status: 404, body: '{"error":"Not found"}') stub_request( :get, "https://npm.fury.io/dependabot/@etag%2Fetag/latest" - ).to_return(status: 404, body: "{\"error\":\"Not found\"}") + ).to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://npm.fury.io/dependabot/@etag%2Fetag"). with(headers: { "Authorization" => "Bearer secret_token" }). to_return(status: 200, body: body) diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker/latest_version_finder_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker/latest_version_finder_spec.rb index d0a7ef67eb6..aad5281f7e7 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker/latest_version_finder_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker/latest_version_finder_spec.rb @@ -213,7 +213,7 @@ before do body = fixture("npm_responses", "prerelease.json") stub_request(:get, "https://registry.npmjs.org/@blep%2Fblep"). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://registry.npmjs.org/@blep%2Fblep"). with(headers: { "Authorization" => "Bearer secret_token" }). to_return(status: 200, body: body) @@ -293,7 +293,7 @@ body = fixture("npm_responses", "prerelease.json") stub_request(:get, "https://registry.npmjs.org/@blep%2Fblep"). with(headers: { "Authorization" => "Bearer secret_token" }). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://registry.npmjs.org/@blep%2Fblep"). with(headers: { "Authorization" => "Basic c2VjcmV0OnRva2Vu" }). to_return(status: 200, body: body) @@ -307,7 +307,7 @@ before do body = fixture("gemfury_response_etag.json") stub_request(:get, "https://npm.fury.io/dependabot/@blep%2Fblep"). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://npm.fury.io/dependabot/@blep%2Fblep"). with(headers: { "Authorization" => "Bearer secret_token" }). to_return(status: 200, body: body) @@ -402,7 +402,7 @@ with(headers: { "Authorization" => "Bearer secret_token" }). to_return( status: 200, - body: "user \"undefined\" is not a member of \"KaterTech\"" + body: 'user "undefined" is not a member of "KaterTech"' ) end @@ -648,7 +648,7 @@ context "when the npm link resolves to a 403" do before do stub_request(:get, registry_listing_url). - to_return(status: 403, body: "{\"error\":\"Forbidden\"}") + to_return(status: 403, body: '{"error":"Forbidden"}') # Speed up spec by stopping any sleep logic allow(version_finder).to receive(:sleep).and_return(true) @@ -663,7 +663,7 @@ context "when the npm link resolves to a 404" do before do stub_request(:get, registry_listing_url). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') # Speed up spec by stopping any sleep logic allow(version_finder).to receive(:sleep).and_return(true) @@ -701,7 +701,7 @@ context "for a namespaced dependency" do before do stub_request(:get, "https://registry.npmjs.org/@blep%2Fblep"). - to_return(status: 404, body: "{\"error\":\"Not found\"}") + to_return(status: 404, body: '{"error":"Not found"}') stub_request(:get, "https://www.npmjs.com/package/@blep/blep"). to_return(status: 200, body: login_form) end From 37f031886cffecdfb7c1c5ffcc9e89e2838a5ed0 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:23:50 -0400 Subject: [PATCH 13/16] rubocop-0.90: nuget --- nuget/lib/dependabot/nuget/file_fetcher.rb | 2 ++ .../lib/dependabot/nuget/file_parser/project_file_parser.rb | 4 ++++ .../file_updater/packages_config_declaration_finder.rb | 2 ++ .../nuget/file_updater/project_file_declaration_finder.rb | 4 ++++ nuget/lib/dependabot/nuget/metadata_finder.rb | 2 ++ .../dependabot/nuget/update_checker/repository_finder.rb | 6 ++++++ 6 files changed, 20 insertions(+) diff --git a/nuget/lib/dependabot/nuget/file_fetcher.rb b/nuget/lib/dependabot/nuget/file_fetcher.rb index 7915e4c5d7f..db5b62a1b42 100644 --- a/nuget/lib/dependabot/nuget/file_fetcher.rb +++ b/nuget/lib/dependabot/nuget/file_fetcher.rb @@ -82,6 +82,7 @@ def packages_config_files end.compact end + # rubocop:disable Metrics/PerceivedComplexity def sln_file_names sln_files = repo_contents.select { |f| f.name.end_with?(".sln") } src_dir = repo_contents.any? { |f| f.name == "src" && f.type == "dir" } @@ -98,6 +99,7 @@ def sln_file_names sln_files.map(&:name) end + # rubocop:enable Metrics/PerceivedComplexity def directory_build_files return @directory_build_files if @directory_build_files_checked diff --git a/nuget/lib/dependabot/nuget/file_parser/project_file_parser.rb b/nuget/lib/dependabot/nuget/file_parser/project_file_parser.rb index 0675e484ef9..f3cc707ed62 100644 --- a/nuget/lib/dependabot/nuget/file_parser/project_file_parser.rb +++ b/nuget/lib/dependabot/nuget/file_parser/project_file_parser.rb @@ -79,6 +79,7 @@ def build_dependency(name, req, version, prop_name, project_file) ) end + # rubocop:disable Metrics/PerceivedComplexity def dependency_name(dependency_node, project_file) raw_name = dependency_node.attribute("Include")&.value&.strip || @@ -93,6 +94,7 @@ def dependency_name(dependency_node, project_file) evaluated_value(raw_name, project_file) end + # rubocop:enable Metrics/PerceivedComplexity def dependency_requirement(dependency_node, project_file) raw_requirement = get_node_version_value(dependency_node) @@ -127,6 +129,7 @@ def req_property_name(dependency_node) named_captures.fetch("property") end + # rubocop:disable Metrics/PerceivedComplexity def get_node_version_value(node) attribute = "Version" value = @@ -137,6 +140,7 @@ def get_node_version_value(node) value == "" ? nil : value end + # rubocop:enable Metrics/PerceivedComplexity def evaluated_value(value, project_file) return value unless value.match?(PROPERTY_REGEX) diff --git a/nuget/lib/dependabot/nuget/file_updater/packages_config_declaration_finder.rb b/nuget/lib/dependabot/nuget/file_updater/packages_config_declaration_finder.rb index e68691447de..20c1ce32b01 100644 --- a/nuget/lib/dependabot/nuget/file_updater/packages_config_declaration_finder.rb +++ b/nuget/lib/dependabot/nuget/file_updater/packages_config_declaration_finder.rb @@ -40,6 +40,7 @@ def declaration_nodes private + # rubocop:disable Metrics/PerceivedComplexity def fetch_declaration_strings deep_find_declarations(packages_config.content).select do |nd| node = Nokogiri::XML(nd) @@ -55,6 +56,7 @@ def fetch_declaration_strings node_requirement == declaring_requirement.fetch(:requirement) end end + # rubocop:enable Metrics/PerceivedComplexity def deep_find_declarations(string) string.scan(DECLARATION_REGEX).flat_map do |matching_node| 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 6cf4784dae9..2dd9f782dfa 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 @@ -52,6 +52,7 @@ def get_element_from_node(node) end # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity def fetch_declaration_strings deep_find_declarations(declaring_file.content).select do |nd| node = Nokogiri::XML(nd) @@ -68,8 +69,10 @@ def fetch_declaration_strings node_requirement == declaring_requirement.fetch(:requirement) end end + # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity def get_node_version_value(node) attribute = "Version" node.attribute(attribute)&.value&.strip || @@ -77,6 +80,7 @@ def get_node_version_value(node) node.attribute(attribute.downcase)&.value&.strip || node.at_xpath("./#{attribute.downcase}")&.content&.strip end + # rubocop:enable Metrics/PerceivedComplexity def deep_find_declarations(string) string.scan(DECLARATION_REGEX).flat_map do |matching_node| diff --git a/nuget/lib/dependabot/nuget/metadata_finder.rb b/nuget/lib/dependabot/nuget/metadata_finder.rb index a6420d49824..e39c0d28259 100644 --- a/nuget/lib/dependabot/nuget/metadata_finder.rb +++ b/nuget/lib/dependabot/nuget/metadata_finder.rb @@ -86,6 +86,7 @@ def dependency_source_url source.fetch("source_url") end + # rubocop:disable Metrics/PerceivedComplexity def auth_header source = dependency.requirements. find { |r| r&.fetch(:source) }&.fetch(:source) @@ -108,6 +109,7 @@ def auth_header { "Authorization" => "Bearer #{token}" } end end + # rubocop:enable Metrics/PerceivedComplexity end end end diff --git a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb index cdb10d0c509..5a262c5b563 100644 --- a/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb +++ b/nuget/lib/dependabot/nuget/update_checker/repository_finder.rb @@ -148,6 +148,8 @@ def config_file_repositories end # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize def repos_from_config_file(config_file) doc = Nokogiri::XML(config_file.content) doc.remove_namespaces! @@ -179,6 +181,8 @@ def repos_from_config_file(config_file) sources end + # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/CyclomaticComplexity def default_repository_details @@ -193,6 +197,7 @@ def default_repository_details } end + # rubocop:disable Metrics/PerceivedComplexity def add_config_file_credentials(sources:, doc:) sources.each do |source_details| key = source_details.fetch(:key) @@ -225,6 +230,7 @@ def add_config_file_credentials(sources:, doc:) sources end + # rubocop:enable Metrics/PerceivedComplexity def remove_wrapping_zero_width_chars(string) string.force_encoding("UTF-8").encode. From ed3020cd70f807b3ffb63d836e0b0592f76fe49f Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:33:33 -0400 Subject: [PATCH 14/16] rubocop-0.90: python --- python/lib/dependabot/python/authed_url_builder.rb | 2 -- python/lib/dependabot/python/file_updater.rb | 2 ++ .../python/file_updater/pipfile_file_updater.rb | 2 ++ .../python/file_updater/pipfile_preparer.rb | 2 -- .../python/file_updater/pyproject_preparer.rb | 4 ++-- .../python/file_updater/requirement_replacer.rb | 4 ++-- python/lib/dependabot/python/requirement.rb | 2 +- .../python/update_checker/latest_version_finder.rb | 2 ++ .../update_checker/pip_compile_version_resolver.rb | 11 ++++++----- .../python/update_checker/pipenv_version_resolver.rb | 11 ++++++++--- .../python/update_checker/poetry_version_resolver.rb | 2 ++ .../python/update_checker/requirements_updater.rb | 5 ++--- 12 files changed, 29 insertions(+), 20 deletions(-) diff --git a/python/lib/dependabot/python/authed_url_builder.rb b/python/lib/dependabot/python/authed_url_builder.rb index b44fb96bf1c..eb553b72108 100644 --- a/python/lib/dependabot/python/authed_url_builder.rb +++ b/python/lib/dependabot/python/authed_url_builder.rb @@ -3,7 +3,6 @@ module Dependabot module Python class AuthedUrlBuilder - # rubocop:disable Metrics/PerceivedComplexity def self.authed_url(credential:) token = credential.fetch("token", nil) url = credential.fetch("index-url") @@ -24,7 +23,6 @@ def self.authed_url(credential:) url.sub("://", "://#{basic_auth_details}@") end - # rubocop:enable Metrics/PerceivedComplexity end end end diff --git a/python/lib/dependabot/python/file_updater.rb b/python/lib/dependabot/python/file_updater.rb index a1752de5a23..16de85814f0 100644 --- a/python/lib/dependabot/python/file_updater.rb +++ b/python/lib/dependabot/python/file_updater.rb @@ -44,6 +44,7 @@ def updated_dependency_files private + # rubocop:disable Metrics/PerceivedComplexity def resolver_type reqs = dependencies.flat_map(&:requirements) changed_reqs = reqs.zip(dependencies.flat_map(&:previous_requirements)). @@ -64,6 +65,7 @@ def resolver_type :requirements end + # rubocop:enable Metrics/PerceivedComplexity def subdependency_resolver return :pipfile if pipfile_lock 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 29936e16d90..012fcf14fc3 100644 --- a/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb @@ -142,6 +142,7 @@ def freeze_other_dependencies(pipfile_content) freeze_top_level_dependencies_except(dependencies) end + # rubocop:disable Metrics/PerceivedComplexity def freeze_dependencies_being_updated(pipfile_content) pipfile_object = TomlRB.parse(pipfile_content) @@ -163,6 +164,7 @@ def freeze_dependencies_being_updated(pipfile_content) TomlRB.dump(pipfile_object) end + # rubocop:enable Metrics/PerceivedComplexity def subdep_type?(type) return false if dependency.top_level? diff --git a/python/lib/dependabot/python/file_updater/pipfile_preparer.rb b/python/lib/dependabot/python/file_updater/pipfile_preparer.rb index 5e217b3e916..fc19b4716d7 100644 --- a/python/lib/dependabot/python/file_updater/pipfile_preparer.rb +++ b/python/lib/dependabot/python/file_updater/pipfile_preparer.rb @@ -46,7 +46,6 @@ def freeze_top_level_dependencies_except(dependencies) TomlRB.dump(pipfile_object) end - # rubocop:disable Metrics/PerceivedComplexity def freeze_dependency(dep_name, pipfile_object, keys) locked_version = version_from_lockfile( keys[:lockfile], @@ -66,7 +65,6 @@ def freeze_dependency(dep_name, pipfile_object, keys) pipfile_object[keys[:pipfile]][dep_name] = "==#{locked_version}" end end - # rubocop:enable Metrics/PerceivedComplexity def update_python_requirement(requirement) pipfile_object = TomlRB.parse(pipfile_content) diff --git a/python/lib/dependabot/python/file_updater/pyproject_preparer.rb b/python/lib/dependabot/python/file_updater/pyproject_preparer.rb index d004add0989..e8aead79458 100644 --- a/python/lib/dependabot/python/file_updater/pyproject_preparer.rb +++ b/python/lib/dependabot/python/file_updater/pyproject_preparer.rb @@ -36,7 +36,7 @@ def sanitize end # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/AbcSize def freeze_top_level_dependencies_except(dependencies) return pyproject_content unless lockfile @@ -71,8 +71,8 @@ def freeze_top_level_dependencies_except(dependencies) TomlRB.dump(pyproject_object) end + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity private diff --git a/python/lib/dependabot/python/file_updater/requirement_replacer.rb b/python/lib/dependabot/python/file_updater/requirement_replacer.rb index 262f26d9ca5..d9d0508896a 100644 --- a/python/lib/dependabot/python/file_updater/requirement_replacer.rb +++ b/python/lib/dependabot/python/file_updater/requirement_replacer.rb @@ -30,8 +30,8 @@ def updated_content updated_dependency_declaration_string end - unless old_requirement == new_requirement - raise "Expected content to change!" if content == updated_content + if old_requirement != new_requirement && content == updated_content + raise "Expected content to change!" end updated_content diff --git a/python/lib/dependabot/python/requirement.rb b/python/lib/dependabot/python/requirement.rb index 500822a10cc..0717c4a6d15 100644 --- a/python/lib/dependabot/python/requirement.rb +++ b/python/lib/dependabot/python/requirement.rb @@ -100,7 +100,7 @@ def convert_tilde_req(req_string) def convert_caret_req(req_string) version = req_string.gsub(/^\^/, "") parts = version.split(".") - parts = parts.fill(0, parts.length...3) + parts.fill(0, parts.length...3) first_non_zero = parts.find { |d| d != "0" } first_non_zero_index = first_non_zero ? parts.index(first_non_zero) : parts.count - 1 diff --git a/python/lib/dependabot/python/update_checker/latest_version_finder.rb b/python/lib/dependabot/python/update_checker/latest_version_finder.rb index 43b119d5f90..136f07de3d0 100644 --- a/python/lib/dependabot/python/update_checker/latest_version_finder.rb +++ b/python/lib/dependabot/python/update_checker/latest_version_finder.rb @@ -166,6 +166,7 @@ def available_versions end end + # rubocop:disable Metrics/PerceivedComplexity def version_details_from_link(link) doc = Nokogiri::XML(link) filename = doc.at_css("a")&.content @@ -181,6 +182,7 @@ def version_details_from_link(link) yanked: link&.include?("data-yanked") } end + # rubocop:enable Metrics/PerceivedComplexity def get_version_from_filename(filename) filename. 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 6e190d18e29..97dfda14933 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 @@ -97,7 +97,6 @@ def fetch_latest_resolvable_version_string(requirement:) end end - # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/AbcSize def handle_pip_compile_errors(error) if error.message.include?("Could not find a version") @@ -114,11 +113,14 @@ def handle_pip_compile_errors(error) check_original_requirements_resolvable end - if error.message.include?('Command "python setup.py egg_info') || - error.message.include?("exit status 1: python setup.py egg_info") + if (error.message.include?('Command "python setup.py egg_info') || + error.message.include?( + "exit status 1: python setup.py egg_info" + )) && + check_original_requirements_resolvable # The latest version of the dependency we're updating is borked # (because it has an unevaluatable setup.py). Skip the update. - return if check_original_requirements_resolvable + return end if error.message.include?("Could not find a version ") && @@ -143,7 +145,6 @@ def handle_pip_compile_errors(error) raise end - # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/AbcSize # Needed because pip-compile's resolver isn't perfect. diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index 1b0a0955dab..91392c27689 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -152,11 +152,14 @@ def handle_pipenv_errors(error) check_original_requirements_resolvable end - if error.message.include?('Command "python setup.py egg_info"') || - error.message.include?("exit status 1: python setup.py egg_info") + if (error.message.include?('Command "python setup.py egg_info"') || + error.message.include?( + "exit status 1: python setup.py egg_info" + )) && + check_original_requirements_resolvable # The latest version of the dependency we're updating is borked # (because it has an unevaluatable setup.py). Skip the update. - return if check_original_requirements_resolvable + return end if error.message.include?("UnsupportedPythonVersion") && @@ -332,6 +335,7 @@ def freeze_other_dependencies(pipfile_content) freeze_top_level_dependencies_except([dependency]) end + # rubocop:disable Metrics/PerceivedComplexity def set_target_dependency_req(pipfile_content, updated_requirement) return pipfile_content unless updated_requirement @@ -352,6 +356,7 @@ def set_target_dependency_req(pipfile_content, updated_requirement) TomlRB.dump(pipfile_object) end + # rubocop:enable Metrics/PerceivedComplexity def subdep_type?(type) return false if dependency.top_level? 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 ed50c17815d..57fb6f0fb4e 100644 --- a/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/poetry_version_resolver.rb @@ -258,6 +258,7 @@ def freeze_other_dependencies(pyproject_content) freeze_top_level_dependencies_except([dependency]) end + # rubocop:disable Metrics/PerceivedComplexity def set_target_dependency_req(pyproject_content, updated_requirement) return pyproject_content unless updated_requirement @@ -284,6 +285,7 @@ def set_target_dependency_req(pyproject_content, updated_requirement) TomlRB.dump(pyproject_object) end + # rubocop:enable Metrics/PerceivedComplexity def subdep_type category = diff --git a/python/lib/dependabot/python/update_checker/requirements_updater.rb b/python/lib/dependabot/python/update_checker/requirements_updater.rb index b0885a9cf65..e5fa27d03fd 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/PerceivedComplexity def updated_pyproject_requirement(req) return req unless latest_resolvable_version return req unless req.fetch(:requirement) @@ -99,8 +98,6 @@ def updated_pyproject_requirement(req) req.merge(requirement: :unfixable) end - # rubocop:enable Metrics/PerceivedComplexity - def update_pyproject_version(req) requirement_strings = req[:requirement].split(",").map(&:strip) @@ -160,6 +157,7 @@ def add_new_requirement_option(req_string) "#{req_string.strip} || #{new_option.strip}" end + # rubocop:disable Metrics/PerceivedComplexity def widen_requirement_range(req_string) requirement_strings = req_string.split(",").map(&:strip) @@ -179,6 +177,7 @@ def widen_requirement_range(req_string) update_requirements_range(requirement_strings) end end + # rubocop:enable Metrics/PerceivedComplexity # rubocop:disable Metrics/PerceivedComplexity def updated_requirement(req) From a3965c62ac47ba9bdeb9a93c9b9a8ca36892ece2 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 14 Sep 2020 14:34:49 -0400 Subject: [PATCH 15/16] rubocop-0.90: terraform --- terraform/lib/dependabot/terraform/file_parser.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terraform/lib/dependabot/terraform/file_parser.rb b/terraform/lib/dependabot/terraform/file_parser.rb index 4fbe4432ef9..d2b9949a3a2 100644 --- a/terraform/lib/dependabot/terraform/file_parser.rb +++ b/terraform/lib/dependabot/terraform/file_parser.rb @@ -163,6 +163,7 @@ def version_from_ref(ref) ref.match(version_regex).named_captures.fetch("version") end + # rubocop:disable Metrics/PerceivedComplexity: # See https://www.terraform.io/docs/modules/sources.html#http-urls for # details of how Terraform handle HTTP(S) sources for modules def get_proxied_source(raw_source) @@ -189,6 +190,7 @@ def get_proxied_source(raw_source) tag.attributes&.fetch("name", nil)&.value == "terraform-get" end&.attributes&.fetch("content", nil)&.value end + # rubocop:enable Metrics/PerceivedComplexity: # rubocop:disable Metrics/PerceivedComplexity def source_type(source_string) From 6fa8e46b5a950a56ca7ee7bffebd91e51171305f Mon Sep 17 00:00:00 2001 From: Pete Wagner Date: Tue, 15 Sep 2020 13:20:43 -0400 Subject: [PATCH 16/16] Apply suggestions from code review Co-authored-by: Philip Harrison --- terraform/lib/dependabot/terraform/file_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/lib/dependabot/terraform/file_parser.rb b/terraform/lib/dependabot/terraform/file_parser.rb index d2b9949a3a2..6d2f2a7657e 100644 --- a/terraform/lib/dependabot/terraform/file_parser.rb +++ b/terraform/lib/dependabot/terraform/file_parser.rb @@ -163,7 +163,7 @@ def version_from_ref(ref) ref.match(version_regex).named_captures.fetch("version") end - # rubocop:disable Metrics/PerceivedComplexity: + # rubocop:disable Metrics/PerceivedComplexity # See https://www.terraform.io/docs/modules/sources.html#http-urls for # details of how Terraform handle HTTP(S) sources for modules def get_proxied_source(raw_source) @@ -190,7 +190,7 @@ def get_proxied_source(raw_source) tag.attributes&.fetch("name", nil)&.value == "terraform-get" end&.attributes&.fetch("content", nil)&.value end - # rubocop:enable Metrics/PerceivedComplexity: + # rubocop:enable Metrics/PerceivedComplexity # rubocop:disable Metrics/PerceivedComplexity def source_type(source_string)