gabynaiman/eternity

View on GitHub

Showing 14 of 14 total issues

Class Repository has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Repository

    attr_reader :name, :id, :branches
    
    def initialize(name, options={})
Severity: Minor
Found in lib/eternity/repository.rb - About 3 hrs to fix

    Method calculate_delta has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def calculate_delta
            if current_commit.nil?
              target_commit.with_index do |target_index| 
                target_index.each_with_object({}) do |(collection, collection_index), hash|
                  hash[collection] = collection_index.ids.each_with_object({}) do |id, h|
    Severity: Minor
    Found in lib/eternity/patch.rb - About 3 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 merge has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def merge(deltas, base_index=nil)
            union(deltas).each_with_object({}) do |(collection, elements), hash|
              hash[collection] = {}
              elements.each do |id, changes|
                current_change = TrackFlatter.flatten changes
    Severity: Minor
    Found in lib/eternity/delta.rb - About 3 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 Commit has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Commit
    
        attr_reader :id
    
        def initialize(id)
    Severity: Minor
    Found in lib/eternity/commit.rb - About 2 hrs to fix

      Method calculate_delta has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def calculate_delta
              if current_commit.nil?
                target_commit.with_index do |target_index| 
                  target_index.each_with_object({}) do |(collection, collection_index), hash|
                    hash[collection] = collection_index.ids.each_with_object({}) do |id, h|
      Severity: Minor
      Found in lib/eternity/patch.rb - About 1 hr to fix

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

            def self.create(options)
              raise 'Author must be present' if options[:author].to_s.strip.empty?
              raise 'Message must be present' if options[:message].to_s.strip.empty?
        
              # TODO: Move to Repository and Patch
        Severity: Minor
        Found in lib/eternity/commit.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 base_of has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.base_of(commit_1, commit_2)
              history_1 = [commit_1.id]
              history_2 = [commit_2.id]
        
              base_1 = commit_1
        Severity: Minor
        Found in lib/eternity/commit.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 checkout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def checkout(options)
              raise "Can't checkout with uncommitted changes" if changes?
        
              locker.lock! :checkout do
                Eternity.logger.info(self.class) { "Checkout #{name} (#{options.map { |k,v| "#{k}: #{v}" }.join(', ')})" }
        Severity: Minor
        Found in lib/eternity/repository.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

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

            def self.all
              sections_count = Eternity.keyspace[:index].sections.count
              names = Eternity.connection.call('KEYS', Eternity.keyspace[:index]['*']).map do |key|
                Restruct::Id.new(key).sections[sections_count]
              end.uniq
        Severity: Minor
        Found in lib/eternity/index.rb and 1 other location - About 40 mins to fix
        lib/eternity/repository.rb on lines 174..179

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

        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 self.all
              sections_count = Eternity.keyspace[:repository].sections.count
              names = Eternity.connection.call('KEYS', Eternity.keyspace[:repository]['*']).map do |key|
                Restruct::Id.new(key).sections[sections_count]
              end.uniq
        Severity: Minor
        Found in lib/eternity/repository.rb and 1 other location - About 40 mins to fix
        lib/eternity/index.rb on lines 31..36

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

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

              def normalize(data)
                if data.kind_of? Hash
                  sorted_data = Hash[data.sort_by { |k,v| k.to_s }]
                  sorted_data.each { |k,v| sorted_data[k] = normalize v }
        
        
        Severity: Minor
        Found in lib/eternity/blob.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 pull has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def pull
              raise "Can't pull with uncommitted changes" if changes?
              raise "Branch not found: #{current_branch}" unless Branch.exists? current_branch
        
              target_commit = Branch[current_branch]
        Severity: Minor
        Found in lib/eternity/repository.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

              delta.each do |collection, changes|
                changes.each do |id, change|
                  args = [id, change['data']].compact
                  self[collection].send(change['action'], *args)
        Severity: Minor
        Found in lib/eternity/repository.rb and 1 other location - About 15 mins to fix
        lib/eternity/index.rb on lines 13..17

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

        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

              delta.each do |collection, elements|
                elements.each do |id, change|
                  args = [id, change['data']].compact
                  self[collection].send change['action'], *args
                end
        Severity: Minor
        Found in lib/eternity/index.rb and 1 other location - About 15 mins to fix
        lib/eternity/repository.rb on lines 38..41

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

        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