Showing 35 of 35 total issues
Class Github
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Github
def self.api_token
@api_token ||= ENV["GITHUB_API_TOKEN"]
end
Method request
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def request(verb, path, body: nil, headers: {}, verbose: true)
path = File.join(registry, path)
headers = default_headers.merge(headers) if default_headers
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class GitMirror
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class GitMirror
def initialize
require "colorize"
require "config"
require "fileutils"
Class Docker
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Docker
def self.registry
@registry ||= ENV.fetch("DOCKER_REGISTRY")
end
Method blast
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def blast
repo.git.fetch
unless repo.git.remote_branch?("origin", base)
puts "!! Skipping #{repo.name}: 'origin/#{base}' not found".light_yellow
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def request(verb, path, body: nil, headers: nil, verbose: true)
headers ||= self.class.auth_header.merge(
"Accept" => "application/json",
"Content-Type" => "application/json"
)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method blast
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def blast
repo.git.fetch
unless repo.git.remote_branch?("origin", base)
puts "!! Skipping #{repo.name}: 'origin/#{base}' not found".light_yellow
Method sync_branch
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def sync_branch(source_remote, source_name, dest_remote, dest_name)
return unless dest_remote && dest_name
source_fq_name = "#{source_remote}/#{source_name}"
dest_fq_name = "#{dest_remote}/#{dest_name}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method clone_repo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def clone_repo(upstream_repo, downstream_repo, path, remote_source)
upstream_remote = settings.git_mirror.remotes[remote_source]
raise "remote '#{remote_source}'' not found in settings" if upstream_remote.nil?
system("git clone #{upstream_remote}/#{upstream_repo}.git #{path} -o upstream")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run
if stub_exists?
puts "A stub gem for #{repo.inspect} already exists."
return
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method client
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.client(path:, clone_source:)
require "minigit"
require_relative "git/minigit_capturing_patch"
retried = false
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method repos_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.repos_for(repo: nil, repo_set: nil, dry_run: false, **_)
Optimist.die("options --repo or --repo_set must be specified") unless repo || repo_set
if repo_set
repos = MultiRepo::RepoSet[repo_set]&.deep_dup
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method destroy_tag
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def destroy_tag(tag, output: false)
client = output ? self.client : self.client.capturing
if dry_run
puts "** dry-run: git tag --delete #{tag}".light_black
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run_script
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def run_script
repo.chdir do
Bundler.with_unbundled_env do
parts = []
parts << "GITHUB_REPO=#{repo.name}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method with_repo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def with_repo(repo, options)
repo_name = downstream_repo_name(repo, options)
puts "\n==== Mirroring #{repo_name} ====".bold.cyan
working_dir = settings.git_mirror.working_directory
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method system
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def system(*args)
puts "+ #{"dry_run: " if dry_run?}#{args.join(" ")}"
return true if dry_run?
args << {} unless args.last.is_a?(Hash)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid parameter lists longer than 5 parameters. [8/5] Open
def initialize(repo, base:, head:, script:, dry_run:, message:, title: nil, **)
- Read upRead up
- Exclude checks
Checks for methods with too many parameters.
The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count, as they add less complexity than positional or optional parameters.
Any number of arguments for initialize
method inside a block of
Struct.new
and Data.define
like this is always allowed:
Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do
def initialize(one:, two:, three:, four:, five:)
end
end
This is because checking the number of arguments of the initialize
method
does not make sense.
NOTE: Explicit block argument &block
is not counted to prevent
erroneous change that is avoided by making block argument implicit.
Example: Max: 3
# good
def foo(a, b, c = 1)
end
Example: Max: 2
# bad
def foo(a, b, c = 1)
end
Example: CountKeywordArgs: true (default)
# counts keyword args towards the maximum
# bad (assuming Max is 3)
def foo(a, b, c, d: 1)
end
# good (assuming Max is 3)
def foo(a, b, c: 1)
end
Example: CountKeywordArgs: false
# don't count keyword args towards the maximum
# good (assuming Max is 3)
def foo(a, b, c, d: 1)
end
This cop also checks for the maximum number of optional parameters.
This can be configured using the MaxOptionalParameters
config option.
Example: MaxOptionalParameters: 3 (default)
# good
def foo(a = 1, b = 2, c = 3)
end
Example: MaxOptionalParameters: 2
# bad
def foo(a = 1, b = 2, c = 3)
end
Method list
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def list(folder, cache: @cache, **kwargs)
folder = folder.to_s
cache_file = "/tmp/artifactory-#{folder.tr("/", "_")}-#{Date.today}.txt"
if cache && File.exist?(cache_file)
File.readlines(cache_file, :chomp => true)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method remote_refs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remote_refs(repo, remote)
return unless remote_exists?(remote)
`git ls-remote #{remote} | grep "heads"`.split("\n").collect do |line|
branch = line.split("/").last
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid parameter lists longer than 5 parameters. [6/5] Open
def initialize(repo_name, title:, due_on:, close:, dry_run: false, **)
- Read upRead up
- Exclude checks
Checks for methods with too many parameters.
The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count, as they add less complexity than positional or optional parameters.
Any number of arguments for initialize
method inside a block of
Struct.new
and Data.define
like this is always allowed:
Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do
def initialize(one:, two:, three:, four:, five:)
end
end
This is because checking the number of arguments of the initialize
method
does not make sense.
NOTE: Explicit block argument &block
is not counted to prevent
erroneous change that is avoided by making block argument implicit.
Example: Max: 3
# good
def foo(a, b, c = 1)
end
Example: Max: 2
# bad
def foo(a, b, c = 1)
end
Example: CountKeywordArgs: true (default)
# counts keyword args towards the maximum
# bad (assuming Max is 3)
def foo(a, b, c, d: 1)
end
# good (assuming Max is 3)
def foo(a, b, c: 1)
end
Example: CountKeywordArgs: false
# don't count keyword args towards the maximum
# good (assuming Max is 3)
def foo(a, b, c, d: 1)
end
This cop also checks for the maximum number of optional parameters.
This can be configured using the MaxOptionalParameters
config option.
Example: MaxOptionalParameters: 3 (default)
# good
def foo(a = 1, b = 2, c = 3)
end
Example: MaxOptionalParameters: 2
# bad
def foo(a = 1, b = 2, c = 3)
end