rosette-proj/rosette-core

View on GitHub

Showing 33 of 33 total issues

Class Repo has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Repo
      attr_reader :jgit_repo

      # Creates a repo instance from the given path.
      #
Severity: Minor
Found in lib/rosette/core/git/repo.rb - About 3 hrs to fix

    Method build_hash has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_hash
            repo = repo_config.repo
            rev_walk = RevWalk.new(repo.jgit_repo)
            rev_commit = repo.get_rev_commit(start_commit_id, rev_walk)
            path_set = (make_path_set(rev_commit) + paths).to_a
    Severity: Minor
    Found in lib/rosette/core/snapshots/snapshot_factory.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

    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 build_hash has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_hash
              repo = repo_config.repo
              rev_walk = RevWalk.new(repo.jgit_repo)
              rev_commit = repo.get_rev_commit(start_commit_id, rev_walk)
              path_set = (make_path_set(rev_commit) + paths).to_a
      Severity: Minor
      Found in lib/rosette/core/snapshots/snapshot_factory.rb - About 1 hr to fix

        Method get_rev_commit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def get_rev_commit(ref_or_commit_id, walker = rev_walker)
                walker.parseCommit(
                  ObjectId.fromString(ref_or_commit_id)
                )
              rescue Java::OrgEclipseJgitErrors::MissingObjectException, Java::JavaLang::IllegalArgumentException => e
        Severity: Minor
        Found in lib/rosette/core/git/repo.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 execute has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def execute
                  stream = StringIO.new
                  snapshot = take_snapshot(repo_config, commit_id, paths)
                  translation_count = 0
                  checksum_list = []
        Severity: Minor
        Found in lib/rosette/core/commands/translations/export_command.rb - About 1 hr to fix

          Method included has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.included(base)
                  base.class_eval do
                    include AASM
          
                    aasm do
          Severity: Minor
          Found in lib/rosette/core/extractor/commit_log_status.rb - About 1 hr to fix

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

                  def process_diff_entry(diff_entry, repo_config, commit)
                    repo_config.get_extractor_configs(diff_entry.getNewPath).each do |extractor_config|
                      source_code = read_object_from_entry(diff_entry, repo_config, extractor_config)
                      line_numbers_to_author = repo_config.repo.blame(diff_entry.getNewPath, commit.getId.name)
            
            
            Severity: Minor
            Found in lib/rosette/core/extractor/commit_processor.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

            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

            Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def initialize(key, meta_key = nil, file = nil, commit_id = nil, author_name = nil, author_email = nil, line_number = nil)
            Severity: Major
            Found in lib/rosette/core/extractor/phrase.rb - About 50 mins to fix

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

                      def valid?(commit_str, repo_name, configuration)
                        if repo_config = configuration.get_repo(repo_name)
                          if commit_str
                            commit = repo_config.repo.get_rev_commit(commit_str)
                            validate_commit(commit)
              Severity: Minor
              Found in lib/rosette/core/validators/commit_validator.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def initialize(repo_name, commit_id, phrase_count = nil, status = nil, commit_datetime = nil, branch_name = nil)
              Severity: Minor
              Found in lib/rosette/core/extractor/commit_log.rb - About 45 mins to fix

                Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def initialize(msg, original_exception, language, file, commit_id)
                Severity: Minor
                Found in lib/rosette/core/errors.rb - About 35 mins to fix

                  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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language