app/models/repo.rb
Class Repo
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Repo < ActiveRecord::Base
BASE_PATH = Rails.root.join("repos")
has_many :branches, :dependent => :destroy
Method synchronize_pr_branches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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
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!
Do not suppress exceptions. Open
Open
rescue Errno::ENOENT
- Read upRead up
- Exclude checks
Checks for rescue
blocks with no body.
Example:
# bad
def some_method
do_something
rescue
end
# bad
begin
do_something
rescue
end
# good
def some_method
do_something
rescue
handle_exception
end
# good
begin
do_something
rescue
handle_exception
end
Example: AllowComments: true (default)
# good
def some_method
do_something
rescue
# do nothing
end
# good
begin
do_something
rescue
# do nothing
end
Example: AllowComments: false
# bad
def some_method
do_something
rescue
# do nothing
end
# bad
begin
do_something
rescue
# do nothing
end
Example: AllowNil: true (default)
# good
def some_method
do_something
rescue
nil
end
# good
begin
do_something
rescue
# do nothing
end
# good
do_something rescue nil
Example: AllowNil: false
# bad
def some_method
do_something
rescue
nil
end
# bad
begin
do_something
rescue
nil
end
# bad
do_something rescue nil