Skip to content

Commit

Permalink
enable Style/* and autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
thepwagner committed Jun 17, 2021
1 parent ca3f24f commit 84a82a6
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 21 deletions.
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,24 @@ Naming/FileName:
Enabled: false
Style/AccessorGrouping:
Enabled: false
Style/ArgumentsForwarding:
Enabled: true
Style/ArrayCoercion:
Enabled: false
Style/BisectedAttrAccessor:
Enabled: false
Style/CaseLikeIf:
Enabled: false
Style/CollectionCompact:
Enabled: true
Style/CombinableLoops:
Enabled: true
Style/DocumentDynamicEvalDefinition:
Enabled: true
Style/Documentation:
Enabled: false
Style/EndlessMethod:
Enabled: true
Style/ExplicitBlockArgument:
Enabled: true
Style/ExponentialNotation:
Expand All @@ -99,16 +107,30 @@ Style/GlobalStdStream:
Enabled: true
Style/HashAsLastArrayItem:
Enabled: false
Style/HashConversion:
Enabled: true
Style/HashEachMethods:
Enabled: false
Style/HashExcept:
Enabled: true
Style/HashLikeCase:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
Style/IfWithBooleanLiteralBranches:
Enabled: true
Style/InPatternThen:
Enabled: true
Style/KeywordParametersOrder:
Enabled: false
Style/MultilineInPatternThen:
Enabled: true
Style/NegatedIfElseCondition:
Enabled: true
Style/NilLambda:
Enabled: true
Style/OptionalBooleanParameter:
Enabled: false
Style/PercentLiteralDelimiters:
Expand All @@ -117,6 +139,10 @@ Style/PercentLiteralDelimiters:
"%W": "()"
"%i": "()"
"%w": "()"
Style/QuotedSymbols:
Enabled: true
Style/RedundantArgument:
Enabled: true
Style/RedundantAssignment:
Enabled: false
Style/RedundantFetchBlock:
Expand All @@ -137,7 +163,11 @@ Style/SlicingWithRange:
Enabled: false
Style/SoleNestedConditional:
Enabled: true
Style/StringChars:
Enabled: true
Style/StringConcatenation:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/SwapValues:
Enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def declares_ruby_version?(node)
end

def ruby_version
requirement = if !ruby_requirement.is_a?(Gem::Requirement)
Dependabot::Bundler::Requirement.new(ruby_requirement)
else
requirement = if ruby_requirement.is_a?(Gem::Requirement)
ruby_requirement
else
Dependabot::Bundler::Requirement.new(ruby_requirement)
end

ruby_version =
Expand Down
2 changes: 1 addition & 1 deletion common/lib/dependabot/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def check_subdependency_metadata
end

def symbolize_keys(hash)
Hash[hash.keys.map { |k| [k.to_sym, hash[k]] }]
hash.keys.map { |k| [k.to_sym, hash[k]] }.to_h
end
end
end
2 changes: 1 addition & 1 deletion common/lib/dependabot/file_updaters/vendor_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def updated_vendor_cache_files(base_directory:)
status = SharedHelpers.run_shell_command(
"git status --untracked-files all --porcelain v1 #{relative_dir}"
)
changed_paths = status.split("\n").map { |l| l.split(" ") }
changed_paths = status.split("\n").map(&:split)
changed_paths.map do |type, path|
# The following types are possible to be returned:
# M = Modified = Default for DependencyFile
Expand Down
4 changes: 2 additions & 2 deletions common/lib/dependabot/git_metadata_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def parse_refs_for_upload_pack
peeled_lines = []

result = upload_pack.lines.each_with_object({}) do |line, res|
full_ref_name = line.split(" ").last
full_ref_name = line.split.last
next unless full_ref_name.start_with?("refs/tags", "refs/heads")

peeled_lines << line && next if line.strip.end_with?("^{}")
Expand Down Expand Up @@ -174,7 +174,7 @@ def scheme_for_uri(uri)
end

def sha_for_update_pack_line(line)
line.split(" ").first.chars.last(40).join
line.split.first.chars.last(40).join
end

def excon_defaults
Expand Down
4 changes: 2 additions & 2 deletions common/lib/dependabot/metadata_finders/base/release_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def release_for_version(version)

def serialize_release(release)
rel = release
title = "## #{rel.name.to_s != '' ? rel.name : rel.tag_name}\n"
title = "## #{rel.name.to_s == '' ? rel.tag_name : rel.name}\n"
body = if rel.body.to_s.gsub(/\n*\z/m, "") == ""
"No release notes provided."
else
Expand All @@ -178,7 +178,7 @@ def serialize_release(release)
end

def release_body_includes_title?(release)
title = release.name.to_s != "" ? release.name : release.tag_name
title = release.name.to_s == "" ? release.tag_name : release.name
release.body.to_s.match?(/\A\s*\#*\s*#{Regexp.quote(title)}/m)
end

Expand Down
4 changes: 2 additions & 2 deletions common/lib/dependabot/pull_request_creator/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def annotate_pull_request(pull_request)

def add_reviewers_to_pull_request(pull_request)
reviewers_hash =
Hash[reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }]
reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }.to_h

github_client_for_source.request_pull_request_review(
source.repo,
Expand Down Expand Up @@ -297,7 +297,7 @@ def invalid_reviewer?(message)

def comment_with_invalid_reviewer(pull_request, message)
reviewers_hash =
Hash[reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }]
reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }.to_h
reviewers = []
reviewers += reviewers_hash[:reviewers] || []
reviewers += (reviewers_hash[:team_reviewers] || []).
Expand Down
2 changes: 1 addition & 1 deletion common/lib/dependabot/pull_request_creator/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def annotate_merge_request(merge_request)

def add_approvers_to_merge_request(merge_request)
approvers_hash =
Hash[approvers.keys.map { |k| [k.to_sym, approvers[k]] }]
approvers.keys.map { |k| [k.to_sym, approvers[k]] }.to_h

gitlab_client_for_source.edit_merge_request_approvers(
source.repo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def sanitize_mentions(doc)
doc.walk do |node|
if node.type == :text &&
node.string_content.match?(MENTION_REGEX)
nodes = if !parent_node_link?(node)
build_mention_nodes(node.string_content)
else
nodes = if parent_node_link?(node)
build_mention_link_text_nodes(node.string_content)
else
build_mention_nodes(node.string_content)
end

nodes.each do |n|
Expand Down
2 changes: 1 addition & 1 deletion common/lib/dependabot/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def raven_context

# Escapes all special characters, e.g. = & | <>
def self.escape_command(command)
command_parts = command.split(" ").map(&:strip).reject(&:empty?)
command_parts = command.split.map(&:strip).reject(&:empty?)
Shellwords.join(command_parts)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def lock_git_dependencies(content)
fetch(keys[:lockfile], []).
find { |d| d["name"] == name }&.
dig("source", "reference")
updated_req_parts = req.split(" ")
updated_req_parts = req.split
updated_req_parts[0] = updated_req_parts[0] + "##{commit_sha}"
json[keys[:manifest]][name] = updated_req_parts.join(" ")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def lock_git_dependencies(content)
fetch(keys[:lockfile], []).
find { |d| d["name"] == name }&.
dig("source", "reference")
updated_req_parts = req.split(" ")
updated_req_parts = req.split
updated_req_parts[0] = updated_req_parts[0] + "##{commit_sha}"
json[keys[:manifest]][name] = updated_req_parts.join(" ")
end
Expand Down
2 changes: 1 addition & 1 deletion hex/lib/dependabot/hex/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def check_required_files
end

def symbolize_keys(hash)
Hash[hash.keys.map { |k| [k.to_sym, hash[k]] }]
hash.keys.map { |k| [k.to_sym, hash[k]] }.to_h
end

def mixfiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def update_uncompiled_files(updated_files)
reject { |file| updated_filenames.include?(file.name) }

args = dependency.to_h
args = Hash[args.keys.map { |k| [k.to_sym, args[k]] }]
args = args.keys.map { |k| [k.to_sym, args[k]] }.to_h
args[:requirements] = new_reqs
args[:previous_requirements] = old_reqs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"modules": [
{
"source": "hashicorp/consul/aws",
"versions": [{ 'version': "0.1.0" }, { 'version': "0.2.0" }]
"versions": [{ "version": "0.1.0" }, { "version": "0.2.0" }]
}
]
}.to_json)
Expand Down

0 comments on commit 84a82a6

Please sign in to comment.