Skip to content

Commit

Permalink
Merge pull request #2496 from dependabot/dependabot/bundler/common/ru…
Browse files Browse the repository at this point in the history
…bocop-tw-0.90.0

Update rubocop requirement from ~> 0.88.0 to ~> 0.90.0 in /common
  • Loading branch information
Pete Wagner committed Sep 15, 2020
2 parents 8991327 + 6fa8e46 commit 4b46832
Show file tree
Hide file tree
Showing 70 changed files with 221 additions and 105 deletions.
71 changes: 70 additions & 1 deletion .rubocop.yml
Expand Up @@ -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: false

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

Expand All @@ -45,6 +84,9 @@ Metrics/ModuleLength:
Metrics/CyclomaticComplexity:
Max: 15

Metrics/PerceivedComplexity:
Max: 10 # default: 8

Metrics/AbcSize:
Max: 35

Expand All @@ -55,7 +97,7 @@ Metrics/BlockLength:
Max: 35
Exclude:
- '*/Rakefile'
- '*/spec/**/*'
- '**/spec/**/*'
- '*/dependabot-*.gemspec'

Metrics/ParameterLists:
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions bundler/lib/dependabot/bundler/file_updater.rb
Expand Up @@ -20,6 +20,7 @@ def self.updated_files_regex
]
end

# rubocop:disable Metrics/PerceivedComplexity
def updated_dependency_files
updated_files = []

Expand Down Expand Up @@ -59,6 +60,7 @@ def updated_dependency_files

updated_files
end
# rubocop:enable Metrics/PerceivedComplexity

private

Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand All @@ -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.
Expand Down
Expand Up @@ -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 }&.
Expand All @@ -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(
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
Expand Up @@ -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)
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cargo/lib/dependabot/cargo/file_fetcher.rb
Expand Up @@ -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|
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cargo/lib/dependabot/cargo/file_parser.rb
Expand Up @@ -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

Expand All @@ -82,6 +83,7 @@ def manifest_dependencies

dependency_set
end
# rubocop:enable Metrics/PerceivedComplexity

def build_dependency(name, requirement, type, file)
Dependency.new(
Expand Down
2 changes: 2 additions & 0 deletions cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb
Expand Up @@ -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/)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions cargo/lib/dependabot/cargo/requirement.rb
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions cargo/lib/dependabot/cargo/update_checker/file_preparer.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cargo/lib/dependabot/cargo/update_checker/version_resolver.rb
Expand Up @@ -82,6 +82,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/)
Expand Down Expand Up @@ -110,6 +111,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

Expand Down
2 changes: 1 addition & 1 deletion common/dependabot-common.gemspec
Expand Up @@ -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"

Expand Down
3 changes: 0 additions & 3 deletions common/lib/dependabot/file_parsers/base/dependency_set.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -89,8 +88,6 @@ def combined_dependency(old_dep, new_dep)
subdependency_metadata: subdependency_metadata
)
end

# rubocop:enable Metrics/PerceivedComplexity
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions common/lib/dependabot/git_commit_checker.rb
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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 }
Expand All @@ -163,6 +164,7 @@ def select_best_changelog(files)

nil
end
# rubocop:enable Metrics/PerceivedComplexity

def tag_for_new_version
@tag_for_new_version ||=
Expand Down
Expand Up @@ -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")

Expand Down Expand Up @@ -51,7 +50,6 @@ def pruned_text

changelog_lines.slice(slice_range).join("\n").sub(/\n*\z/, "")
end
# rubocop:enable Metrics/PerceivedComplexity

private

Expand Down
2 changes: 0 additions & 2 deletions common/lib/dependabot/pull_request_creator/branch_namer.rb
Expand Up @@ -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
Expand All @@ -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|
Expand Down
2 changes: 2 additions & 0 deletions common/lib/dependabot/pull_request_creator/github.rb
Expand Up @@ -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
Expand All @@ -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?
Expand Down

0 comments on commit 4b46832

Please sign in to comment.