Showing 20 of 20 total issues

Class Record has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Record

    attr_reader :attributes

    Attr = Attribute = Norm::Attribute
Severity: Minor
Found in lib/norm/record.rb - About 5 hrs to fix

    Class Attributes has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Attributes
        EMPTY = [].freeze
        NonexistentAttributeError = Class.new(Error)
    
        def self.names
    Severity: Minor
    Found in lib/norm/attributes.rb - About 4 hrs to fix

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

        class Repository
      
          attr_reader :record_class, :connection_manager, :processor, :reader, :writer
      
          def initialize(record_class,
      Severity: Minor
      Found in lib/norm/repository.rb - About 3 hrs to fix

        Class Collection has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Collection
              attr_reader :records, :record_class
        
              def self.for(records)
                if records.empty?
        Severity: Minor
        Found in lib/norm/record/collection.rb - About 2 hrs to fix

          Class Record has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Record
              module Delegator
          
                def self.included(base)
                  base.extend ClassMethods
          Severity: Minor
          Found in lib/norm/record/delegator.rb - About 2 hrs to fix

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

                class Select < Statement
            
                  def initialize(*args)
                    @withs   = WithClause.new
                    @selects = SelectClause.new
            Severity: Minor
            Found in lib/norm/sql/select.rb - About 2 hrs to fix

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

                  class Interval
                    extend Loading
                    include Comparable
              
                    YEAR, MONTH, DAY, HOUR, MINUTE, SECOND = 0..5
              Severity: Minor
              Found in lib/norm/attribute/interval.rb - About 2 hrs to fix

                Method attribute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.attribute(name, loader)
                      name = name.to_sym
                      my_names = names | [name]
                      define_singleton_method(:names) { super() | my_names }
                      define_method("_set_#{name}") { |obj|
                Severity: Minor
                Found in lib/norm/attributes.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

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

                    def update_many(records, constraint_delegate: nil)
                      records = Norm::Record::Collection(records)
                      return false unless records.valid?
                
                      yield ->(result, conn) {
                Severity: Minor
                Found in lib/norm/record_mutation_processor.rb and 1 other location - About 1 hr to fix
                lib/norm/record_mutation_processor.rb on lines 45..58

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

                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 insert_many(records, constraint_delegate: nil)
                      records = Norm::Record::Collection(records)
                      return false unless records.valid?
                
                      yield ->(result, conn) {
                Severity: Minor
                Found in lib/norm/record_mutation_processor.rb and 1 other location - About 1 hr to fix
                lib/norm/record_mutation_processor.rb on lines 74..87

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

                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 insert_one(record, constraint_delegate: nil)
                      return false unless record.valid?
                
                      yield ->(result, conn) {
                        assert_result_size(1, result)
                Severity: Minor
                Found in lib/norm/record_mutation_processor.rb and 1 other location - About 50 mins to fix
                lib/norm/record_mutation_processor.rb on lines 60..72

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

                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 update_one(record, constraint_delegate: nil)
                      return false unless record.valid?
                
                      yield ->(result, conn) {
                        assert_result_size(1, result)
                Severity: Minor
                Found in lib/norm/record_mutation_processor.rb and 1 other location - About 50 mins to fix
                lib/norm/record_mutation_processor.rb on lines 31..43

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

                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 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def initialize(hour = 0, min = 0, sec = 0, fraction = 0, offset = 0)
                Severity: Minor
                Found in lib/norm/attribute/time.rb - About 35 mins to fix

                  Method load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def load(object, *args)
                          send @dispatch[object.class], object, *args
                        rescue NoMethodError => e
                          raise e if respond_to?(@dispatch[object.class], true)
                          ancestor = object.class.ancestors.detect { |mod|
                  Severity: Minor
                  Found in lib/norm/attribute/loading.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 build_from_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def build_from_hash(hash)
                          sql    = []
                          params = []
                          hash.each do |attr, value|
                            attr = Attribute::Identifier(attr)
                  Severity: Minor
                  Found in lib/norm/sql/predicate_fragment.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 insert_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def insert_one(record, constraint_delegate: nil)
                        return false unless record.valid?
                  
                        yield ->(result, conn) {
                          assert_result_size(1, result)
                  Severity: Minor
                  Found in lib/norm/record_mutation_processor.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 update_many has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update_many(records, constraint_delegate: nil)
                        records = Norm::Record::Collection(records)
                        return false unless records.valid?
                  
                        yield ->(result, conn) {
                  Severity: Minor
                  Found in lib/norm/record_mutation_processor.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 insert_many has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def insert_many(records, constraint_delegate: nil)
                        records = Norm::Record::Collection(records)
                        return false unless records.valid?
                  
                        yield ->(result, conn) {
                  Severity: Minor
                  Found in lib/norm/record_mutation_processor.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 finalize_placeholders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def finalize_placeholders(statement)
                        index = 0
                        sql    = statement.sql.dup
                        params = statement.params.dup
                        sql.gsub!(PLACEHOLDER_FINALIZATION_REGEXP) { |match|
                  Severity: Minor
                  Found in lib/norm/connection.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 update_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update_one(record, constraint_delegate: nil)
                        return false unless record.valid?
                  
                        yield ->(result, conn) {
                          assert_result_size(1, result)
                  Severity: Minor
                  Found in lib/norm/record_mutation_processor.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