codetriage/codetriage

View on GitHub

Showing 27 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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ActiveRecord::Schema.define do
                    create_table :users, force: true do |t|
                      t.string :name
                      t.timestamps null: false
                    end
                  Severity: Minor
                  Found in perf_scripts/dirty_tracking.rb and 1 other location - About 45 mins to fix
                  perf_scripts/cache_version.rb on lines 8..18

                  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 40.

                  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

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ActiveRecord::Schema.define do
                    create_table :users, force: true do |t|
                      t.string :name
                      t.timestamps null: false
                    end
                  Severity: Minor
                  Found in perf_scripts/cache_version.rb and 1 other location - About 45 mins to fix
                  perf_scripts/dirty_tracking.rb on lines 7..17

                  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 40.

                  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

                  Further Reading

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    around_perform do |job, block|
                      repo_or_id = job.arguments[0]
                      if repo_or_id.is_a?(Integer)
                        repo = Repo.find(repo_or_id)
                      else
                  Severity: Minor
                  Found in app/jobs/repo_based_job.rb and 1 other location - About 30 mins to fix
                  app/jobs/user_based_job.rb on lines 29..39

                  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 33.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    around_perform do |job, block|
                      user_or_id = job.arguments[0]
                      if user_or_id.is_a?(Integer)
                        user = User.find(user_or_id)
                      else
                  Severity: Minor
                  Found in app/jobs/user_based_job.rb and 1 other location - About 30 mins to fix
                  app/jobs/repo_based_job.rb on lines 29..39

                  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 33.

                  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

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language