rosette-proj/rosette-core

View on GitHub

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

            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_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 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_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 each_commit_in_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def each_commit_in_range(start_ref, end_ref)
                          if block_given?
                            commit_walker = RevWalk.new(jgit_repo).tap do |walker|
                              walker.markStart(get_rev_commit(start_ref, walker))
                            end
                  Severity: Minor
                  Found in lib/rosette/core/git/repo.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

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

                        def extract_each_from(source_code)
                          if block_given?
                            each_function_call(source_code) do |node, line_number|
                              if valid_name?(node) && valid_args?(node)
                                yield make_phrase(get_key(node), get_meta_key(node)), line_number
                  Severity: Minor
                  Found in lib/rosette/core/extractor/extractor.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

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

                        def find_first_non_merge_parent(ref)
                          each_commit_starting_at(ref).with_index do |prev_rev, idx|
                            next if idx == 0
                            break prev_rev if prev_rev.getParentCount <= 1
                          end
                  Severity: Minor
                  Found in lib/rosette/core/git/repo.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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language