ari/jobsworth

View on GitHub
app/models/task_filter.rb

Summary

Maintainability
C
1 day
Test Coverage

Class TaskFilter has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class TaskFilter < ActiveRecord::Base
  # column `name` is of type `VARCHAR(255)`.
  # Note that MySQL 5.x+ and PostgreSQL both track length of "characters" and not "bytes"
  MAXIMUM_NAME_LENGTH = 255

Severity: Minor
Found in app/models/task_filter.rb - About 4 hrs to fix

    File task_filter.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class TaskFilter < ActiveRecord::Base
      # column `name` is of type `VARCHAR(255)`.
      # Note that MySQL 5.x+ and PostgreSQL both track length of "characters" and not "bytes"
      MAXIMUM_NAME_LENGTH = 255
    
    
    Severity: Minor
    Found in app/models/task_filter.rb - About 3 hrs to fix

      Method generate_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate_name
          counter = 0
          arr=[]
          types=['Project', 'Milestone', 'Status', 'Client', 'User']
          types.each do |type|
      Severity: Minor
      Found in app/models/task_filter.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 column_name_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def column_name_for(class_type)
          if class_type == 'User'
            return "task_users.type= 'TaskOwner' AND task_users.user_id"
          elsif class_type == 'Project'
            return 'tasks.project_id'
      Severity: Minor
      Found in app/models/task_filter.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

      Avoid too many return statements within this method.
      Open

            return 'tasks.company_id'
      Severity: Major
      Found in app/models/task_filter.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return "#{ class_type.downcase }_id"
        Severity: Major
        Found in app/models/task_filter.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return 'tasks.milestone_id'
          Severity: Major
          Found in app/models/task_filter.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return 'task_tags.tag_id'
            Severity: Major
            Found in app/models/task_filter.rb - About 30 mins to fix

              Method compose_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def compose_sql(arg1, arg2)
                  if arg1.blank?
                    if arg2.blank?
                      ''
                    else
              Severity: Minor
              Found in app/models/task_filter.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

              There are no issues that match your filters.

              Category
              Status