rosette-proj/rosette-core

View on GitHub
lib/rosette/core/commands/git/diff_base_command.rb

Summary

Maintainability
C
1 day
Test Coverage

Class DiffBaseCommand has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

      class DiffBaseCommand < GitCommand
        attr_reader :strict
        alias_method :strict?, :strict

        def initialize(*args)
Severity: Minor
Found in lib/rosette/core/commands/git/diff_base_command.rb - About 2 hrs to fix

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

            def meta_key_head_to_diff_point(head_phrases, diff_point_phrases)
              if block_given?
                # iterate over all head phrases that have meta keys
                head_phrases.each do |head_phrase|
                  idx = diff_point_phrases.find_index do |diff_point_phrase|
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.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 key_diff_point_to_head has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def key_diff_point_to_head(head_phrases, diff_point_phrases)
              if block_given?
                diff_point_phrases.each do |diff_point_phrase|
                  phrase = head_phrases.find do |head_phrase|
                    head_phrase.key == diff_point_phrase.key &&
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.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 meta_key_diff_point_to_head has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def meta_key_diff_point_to_head(head_phrases, diff_point_phrases)
              if block_given?
                diff_point_phrases.each do |diff_point_phrase|
                  idx = head_phrases.find_index do |head_phrase|
                    head_phrase.meta_key == diff_point_phrase.meta_key &&
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.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 key_head_to_diff_point has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def key_head_to_diff_point(head_phrases, diff_point_phrases)
              if block_given?
                head_phrases.each do |head_phrase|
                  phrase = diff_point_phrases.find do |diff_point_phrase|
                    diff_point_phrase.key == head_phrase.key &&
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.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 ensure_commits_have_been_processed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def ensure_commits_have_been_processed(commits)
              commits.uniq.each do |commit_id|
                if commit_id
                  unless commit_exists?(repo_name, commit_id)
                    raise Errors::UnprocessedCommitError,
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.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

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

            def key_diff(partitioned_head_phrases, partitioned_diff_point_phrases)
              diff = Hash.new { |hash, key| hash[key] = [] }
    
              key_head_to_diff_point(
                partitioned_head_phrases.first,
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.rb and 1 other location - About 55 mins to fix
    lib/rosette/core/commands/git/diff_base_command.rb on lines 143..160

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

    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

            def meta_key_diff(partitioned_head_phrases, partitioned_diff_point_phrases)
              diff = Hash.new { |hash, key| hash[key] = [] }
    
              meta_key_head_to_diff_point(
                partitioned_head_phrases.last,
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.rb and 1 other location - About 55 mins to fix
    lib/rosette/core/commands/git/diff_base_command.rb on lines 90..107

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

    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

            def key_diff_point_to_head(head_phrases, diff_point_phrases)
              if block_given?
                diff_point_phrases.each do |diff_point_phrase|
                  phrase = head_phrases.find do |head_phrase|
                    head_phrase.key == diff_point_phrase.key &&
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.rb and 1 other location - About 35 mins to fix
    lib/rosette/core/commands/git/diff_base_command.rb on lines 198..211

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

    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

            def meta_key_diff_point_to_head(head_phrases, diff_point_phrases)
              if block_given?
                diff_point_phrases.each do |diff_point_phrase|
                  idx = head_phrases.find_index do |head_phrase|
                    head_phrase.meta_key == diff_point_phrase.meta_key &&
    Severity: Minor
    Found in lib/rosette/core/commands/git/diff_base_command.rb and 1 other location - About 35 mins to fix
    lib/rosette/core/commands/git/diff_base_command.rb on lines 126..139

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

    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

    There are no issues that match your filters.

    Category
    Status