codetriage/codetriage

View on GitHub

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
Severity: Minor
Found in app/models/repo.rb - About 5 hrs to fix

    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
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      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 = {}
      Severity: Minor
      Found in app/models/mail_builder/grouped_issues_docs.rb - About 1 hr to fix

        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: [],
        Severity: Minor
        Found in app/mailers/user_mailer.rb - About 1 hr to fix

          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)
          Severity: Minor
          Found in app/jobs/populate_issues_job.rb - About 1 hr to fix

            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)
            Severity: Minor
            Found in app/jobs/populate_issues_job.rb - About 1 hr to fix

            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: [],
            Severity: Minor
            Found in app/mailers/user_mailer.rb - About 1 hr to fix

            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?
            
            
            Severity: Minor
            Found in app/models/issue_assigner.rb - About 1 hr to fix

            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)
            Severity: Minor
            Found in app/controllers/university_controller.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in app/controllers/badges_controller.rb - About 1 hr to fix

                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"
                Severity: Minor
                Found in app/controllers/users/omniauth_callbacks_controller.rb - About 55 mins to fix

                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);
                Severity: Major
                Found in app/assets/javascripts/replace_text.js - About 45 mins to fix

                  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
                  Severity: Minor
                  Found in app/models/github_fetcher/resource.rb - About 45 mins to fix

                  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
                  Severity: Minor
                  Found in app/models/doc_mailer_maker.rb - About 35 mins to fix

                  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
                  Severity: Minor
                  Found in lib/docs_doctor/parsers/ruby/yard.rb - About 35 mins to fix

                  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
                  
                  
                  Severity: Minor
                  Found in app/models/repo.rb - About 35 mins to fix

                  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
                  Severity: Major
                  Found in app/jobs/send_daily_triage_email_job.rb - About 30 mins to fix

                    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
                    Severity: Minor
                    Found in app/models/repo_subscription.rb - About 25 mins to fix

                    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
                    Severity: Minor
                    Found in app/models/issue.rb - About 25 mins to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language