Showing 53 of 53 total issues
Class CommitMonitor
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class CommitMonitor
include Sidekiq::Worker
sidekiq_options :queue => :miq_bot_glacial, :retry => false
include SidekiqWorkerMixin
Class CrossRepoTest
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class CrossRepoTest < Base
# Reference to the branch we are creating off of origin/master
attr_reader :branch_ref
# The user calling the command
Class Repo
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Repo < ActiveRecord::Base
BASE_PATH = Rails.root.join("repos")
has_many :branches, :dependent => :destroy
Class Branch
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Branch
attr_reader :branch
def initialize(branch)
@branch = branch
end
Method synchronize_pr_branches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def synchronize_pr_branches(expected)
raise "repo cannot not have PR branches" unless can_have_prs?
git_fetch # TODO: Let's get rid of this!
- 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 synchronize_pr_branches
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def synchronize_pr_branches(expected)
raise "repo cannot not have PR branches" unless can_have_prs?
git_fetch # TODO: Let's get rid of this!
Method dispatch!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def dispatch!(issuer:, text:)
lines = text.split("\n")
lines.each do |line|
match = command_regex.match(line.strip)
next unless match
- 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 check_line
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_line(line, patch)
file_path = patch.delta.new_file[:path]
Settings.diff_content_checker.offenses.each do |offender, options|
next if options.except.try(:any?) { |except| file_path.start_with?(except) }
- 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 _execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _execute(issuer:, value:)
unremovable = []
valid, invalid = extract_label_names(value)
process_extracted_labels(issuer, valid, invalid, unremovable)
- 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 check_complete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_complete
# NOTE: The mutex may need to be upgraded to a database row lock
# if we go multi-process
SEMAPHORE.synchronize do
begin
- 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 _execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _execute(issuer:, value:)
user = value.strip.delete('@')
if valid_assignee?(user)
if requested_reviewers.include?(user)
- 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 create_all_from_master
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create_all_from_master(name)
Repo.all.each do |repo|
next if repo.branches.exists?(:name => name)
b = repo.branches.new(:name => 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 status_summary
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def status_summary
changed, added, deleted = raw_diff.stat
[
changed.positive? ? "#{changed} #{"file".pluralize(changed)} changed" : nil,
added.positive? ? "#{added} #{"insertion".pluralize(added)}(+)" : nil,
- 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 find_branch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_branch(branch_id, required_mode = nil)
@branch ||= Branch.where(:id => branch_id).first
if branch.nil?
logger.warn("Branch #{branch_id} no longer exists. Skipping.")
- 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 process_branch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_branch
labels = []
label_rules.each do |rule|
if diff_file_names.any? { |file_name| file_name =~ rule.regex }
labels << rule.label
- 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 check_diff_lines
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_diff_lines
branch.git_service.diff.with_each_line do |line, _parent_hunk, parent_patch|
next unless line.addition?
check_line(line, parent_patch)
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 dedup_repo_list
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dedup_repo_list(repo_list)
repo_list
.sort # Unadorned repo name will always sort before adorned repo names
.uniq
.slice_when { |a, b| bare_repo_name(a) != bare_repo_name(b) }
- 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 file_status
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def file_status
raw_diff.patches.each_with_object({}) do |patch, h|
if new_file = patch.delta.new_file.try(:[], :path)
additions = h.fetch_path(new_file, :additions) || 0
h.store_path(new_file, :additions, (additions + patch.additions))
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def validate_labels(label_names)
# First reload the cache if there are any invalid labels
GithubService.refresh_labels(issue.fq_repo_name) unless label_names.all? { |l| GithubService.valid_label?(issue.fq_repo_name, l) }
# Then see if any are *still* invalid and split the list
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 25.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
def validate_labels(label_names)
# First reload the cache if there are any invalid labels
GithubService.refresh_labels(issue.fq_repo_name) unless label_names.all? { |l| GithubService.valid_label?(issue.fq_repo_name, l) }
# Then see if any are *still* invalid and split the list
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 25.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76