Showing 19 of 27 total issues
Class Repo
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class Repo < ActiveRecord::Base
# Now done at the DB level # validates :name, uniqueness: {scope: :user_name, case_sensitive: false }
attr_accessor :skip_validation
validate :github_url_exists, on: :create, unless: :skip_validation
validates :name, :user_name, presence: true
Class User
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
# Include default devise modules (but not :registerable). Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable,
# :omniauthable, and :registerable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :omniauthable
Method initialize
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user_id:, assignment_ids: [], read_doc_ids: [], write_doc_ids: [], random_seed: Random.new_seed)
@active = false
@sub_hashes = {}
@repo_id_to_sub = {}
@doc_comments_hash = {}
Method send_daily_triage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_daily_triage(
user_id:,
assignment_ids:,
email_at:,
read_doc_ids: [],
Method populate_issues
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def populate_issues(page_number)
fetcher = repo.issues_fetcher
fetcher.page = page_number
fetcher.call(retry_on_bad_token: 3)
Method populate_issues
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def populate_issues(page_number)
fetcher = repo.issues_fetcher
fetcher.page = page_number
fetcher.call(retry_on_bad_token: 3)
- 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 send_daily_triage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def send_daily_triage(
user_id:,
assignment_ids:,
email_at:,
read_doc_ids: [],
- 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 assign_issues_for_sub
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private def assign_issues_for_sub(sub)
issues = issues_for_sub(sub)
return if issues.empty?
- 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 show
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
case params[:id]
when "squash"
@page_title = "Please squash your commits"
set_title(@page_title)
Method make_shield
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def make_shield(name:, count:, color_a: "555", color_b: "4c1", logo_width: 0, logo_padding: 0)
name_width = (width_of(name) + 10).to_f
count_width = (width_of(count) + 10).to_f
total_width = name_width + count_width
svg = <<~EOS
Method github
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def github
@user = GitHubAuthenticator.authenticate(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = if @user.valid_email?
I18n.t "devise.omniauth_callbacks.success", kind: "GitHub"
- 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 deeply nested control flow statements. Open
(function($){$.fn.replaceText=function(b,a,c){return this.each(function(){var f=this.firstChild,g,e,d=[];if(f){do{if(f.nodeType===3){g=f.nodeValue;e=g.replace(b,a);if(e!==g){if(!c&&/</.test(e)){$(f).before(e);d.push(f)}else{f.nodeValue=e}}}}while(f=f.nextSibling)}d.length&&$(d).remove()})}})(jQuery);
Method call
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def call(retry_on_bad_token: false)
resp = response
return resp unless bad_token?
return resp unless retry_on_bad_token
- 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 assign_docs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def assign_docs()
subs.flat_map do |sub|
if !yield(sub)
Rails.logger.debug "Filtered: #{sub.inspect}"
next
- 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 hash_for_entity
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def hash_for_entity(obj, repo)
if obj.is_a? YARD::CodeObjects::MethodObject
# attr_writer, attr_reader don't need docs
# document original method instead
# don't document initialize
- 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 populate_docs!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def populate_docs!(commit_sha: commit_sha_fetcher.commit_sha, location: nil, has_subscribers: !docs_subscriber_count.zero?)
return "Skipped, lang not supported" unless can_doctor_docs?
return "Skipped, no commit SHA" unless commit_sha
return "Skipped, no subscribers" unless has_subscribers
- 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 too many return
statements within this method. Open
return false
Method set_read_write
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_read_write
if read_limit.blank? || read_limit.zero?
self.read = false
else
self.read = 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 valid_for_user?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def valid_for_user?(user, can_access_network: !Rails.env.test?, repo: nil)
if can_access_network
update_issue!(repo)
return false if commenting_users(repo).include?(user.github)
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"