kaspernj/baza_models

View on GitHub

Showing 38 of 38 total issues

Class Query has 56 methods (exceeds 20 allowed). Consider refactoring.
Open

class BazaModels::Query
  AutoAutoloader.autoload_sub_classes(self, __FILE__)

  include BazaModels::Query::Pagination

Severity: Major
Found in lib/baza_models/query.rb - About 1 day to fix

    Class Model has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class BazaModels::Model
      AutoAutoloader.autoload_sub_classes(self, __FILE__)
    
      include BelongsToRelations
      include Delegation
    Severity: Minor
    Found in lib/baza_models/model.rb - About 5 hrs to fix

      File query.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "array_enumerator"
      
      class BazaModels::Query
        AutoAutoloader.autoload_sub_classes(self, __FILE__)
      
      
      Severity: Minor
      Found in lib/baza_models/query.rb - About 5 hrs to fix

        Method to_sql has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          def to_sql # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
            sql = "SELECT "
        
            if @selects.empty?
              sql << "#{@db.sep_table}#{@model.table_name}#{@db.sep_table}.*"
        Severity: Minor
        Found in lib/baza_models/query/sql_generator.rb - About 5 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

        File model.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "string-cases"
        
        class BazaModels::Model
          AutoAutoloader.autoload_sub_classes(self, __FILE__)
        
        
        Severity: Minor
        Found in lib/baza_models/model.rb - About 3 hrs to fix

          Method to_sql has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def to_sql # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
              sql = "SELECT "
          
              if @selects.empty?
                sql << "#{@db.sep_table}#{@model.table_name}#{@db.sep_table}.*"
          Severity: Major
          Found in lib/baza_models/query/sql_generator.rb - About 2 hrs to fix

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

              def save(args = {})
                if args[:validate] == false || valid?
                  new_record = new_record?
                  fire_callbacks(:before_save)
                  self.updated_at = Time.now if changed? && has_attribute?(:updated_at)
            Severity: Minor
            Found in lib/baza_models/model/manipulation.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 has_one has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def has_one(relation_name, *all_args)
                  # rubocop:enable Naming/PredicateName
            
                  args = all_args.pop
            
            
            Severity: Minor
            Found in lib/baza_models/model/has_one_relations.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 belongs_to has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def belongs_to(relation_name, args = {})
                  relation = {
                    type: :belongs_to,
                    relation_name: relation_name,
                    table_name: args[:table_name] || StringCases.pluralize(relation_name),
            Severity: Minor
            Found in lib/baza_models/model/belongs_to_relations.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 where has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def where(*args)
                first_arg = args.first
                new_wheres = @wheres.dup
            
                if first_arg.is_a?(String)
            Severity: Minor
            Found in lib/baza_models/query.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 real_attributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def real_attributes(attributes)
                new_attributes = {}
                attributes.each do |attribute_name, attribute_value|
                  belongs_to_relations = self.class.instance_variable_get(:@belongs_to_relations)
            
            
            Severity: Minor
            Found in lib/baza_models/model.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 destroy has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def destroy
                if new_record?
                  errors.add(:base, "cannot destroy new record")
                  false
                else
            Severity: Minor
            Found in lib/baza_models/model/manipulation.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 valid? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def valid?
                fire_callbacks(:before_validation)
            
                if new_record?
                  fire_callbacks(:before_validation_on_create)
            Severity: Minor
            Found in lib/baza_models/model/validations.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 parse_relation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def parse_relation
                current_name = []
                relationships = @klass.relationships
            
                loop do
            Severity: Minor
            Found in lib/baza_models/ransacker/relationship_scanner.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 has_one has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def has_one(relation_name, *all_args)
                  # rubocop:enable Naming/PredicateName
            
                  args = all_args.pop
            
            
            Severity: Minor
            Found in lib/baza_models/model/has_one_relations.rb - About 1 hr to fix

              Method where has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def where(*args)
                  first_arg = args.first
                  new_wheres = @wheres.dup
              
                  if first_arg.is_a?(String)
              Severity: Minor
              Found in lib/baza_models/query.rb - About 1 hr to fix

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

                    def has_many(relation_name, *all_args)
                      # rubocop:enable Naming/PredicateName
                
                      args = all_args.pop
                
                
                Severity: Minor
                Found in lib/baza_models/model/has_many_relations.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 has_many has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def has_many(relation_name, *all_args)
                      # rubocop:enable Naming/PredicateName
                
                      args = all_args.pop
                
                
                Severity: Minor
                Found in lib/baza_models/model/has_many_relations.rb - About 1 hr to fix

                  Method belongs_to has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def belongs_to(relation_name, args = {})
                        relation = {
                          type: :belongs_to,
                          relation_name: relation_name,
                          table_name: args[:table_name] || StringCases.pluralize(relation_name),
                  Severity: Minor
                  Found in lib/baza_models/model/belongs_to_relations.rb - About 1 hr to fix

                    Method add_filters_to_query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def add_filters_to_query
                        @add_filters_to_query_executed = true
                        return unless @params
                    
                        ransackable_scopes = @klass.ransackable_scopes.map(&:to_s) if @klass.respond_to?(:ransackable_scopes)
                    Severity: Minor
                    Found in lib/baza_models/ransacker.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

                    Severity
                    Category
                    Status
                    Source
                    Language