Applicat/rails_info

View on GitHub
app/models/version_control/filter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method files_by_category has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def files_by_category
    return {} unless valid?
    
    return @files_by_category if @files_by_category
    
Severity: Minor
Found in app/models/version_control/filter.rb - About 2 hrs 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 add_commit_to_files has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def add_commit_to_files(commit)
    @previous_revision = nil
    
    return if filter_merges && commit.message.match(/^Merge branch /)
    
Severity: Minor
Found in app/models/version_control/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

Consider simplifying this complex logical expression.
Open

    if path.blank? && author.blank? && id.blank? && message.blank? && story.blank? && tasks.blank? && from.blank? && to.blank?
      @errors['base'] = 'set at least one of these: path, author, id, message, story, tasks, from, to'
    end
Severity: Critical
Found in app/models/version_control/filter.rb - About 1 hr to fix

    Method files_by_category has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def files_by_category
        return {} unless valid?
        
        return @files_by_category if @files_by_category
        
    Severity: Minor
    Found in app/models/version_control/filter.rb - About 1 hr to fix

      Method add_commit_to_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_commit_to_file(file_path, commit)
          category = :misc
                  
          if file_path.match(/\//)
            @files_by_category.each do |current_category, setting|
      Severity: Minor
      Found in app/models/version_control/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 commit_attributes_match_criteria? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def commit_attributes_match_criteria?(commit)
          if filter_merges && commit.message.match(/^Merge branch /)
            return false
          elsif commit.message.match(message) && (author.blank? || commit.author.name == author) && between_timespan?(commit.committed_date)
            return true
      Severity: Minor
      Found in app/models/version_control/filter.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

      Method between_timespan? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def between_timespan?(timestamp)
          return true if from.blank? && to.blank?
          
          from_valid = from.present? && Time.parse(from) <= timestamp
          to_valid = to.present? && Time.parse(to) >= timestamp
      Severity: Minor
      Found in app/models/version_control/filter.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

      Method users has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def users
          return @users if @users
          
          @users = []
          
      Severity: Minor
      Found in app/models/version_control/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

      Method _valid? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def _valid?
          @errors ||= {}
          
          ['workspace', 'repository', 'project_slug', 'branch'].each do |field|
            @errors[field] = "can't be blank." if self.send(field).blank?
      Severity: Minor
      Found in app/models/version_control/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

      Consider simplifying this complex logical expression.
      Open

          elsif (from.blank? || to.blank?) && ((from.present? && from_valid) || (to.present? && to_valid))
            true
          else 
            false
      Severity: Major
      Found in app/models/version_control/filter.rb - About 40 mins to fix

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

          def try_two_times(message = '')
            tries ||= 1
            
            logger.info "#{Time.now.strftime('%H:%M:%S')} #{message} (try ##{tries})"
            
        Severity: Minor
        Found in app/models/version_control/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