HornsAndHooves/pg_saurus

View on GitHub

Showing 20 of 20 total issues

Method foreign_keys has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def foreign_keys(table, stream)
    if (foreign_keys = @connection.foreign_keys(table)).any?
      add_foreign_key_statements = foreign_keys.map do |foreign_key|

        from_table = if foreign_key.from_schema && foreign_key.from_schema != 'public'
Severity: Minor
Found in lib/pg_saurus/schema_dumper/foreign_key_methods.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 indexes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def indexes(table_name)
          scope = quoted_scope(table_name)

          result = query(<<-SQL, "SCHEMA")
            SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid), t.oid,

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

        def indexes(table_name)
          scope = quoted_scope(table_name)

          result = query(<<-SQL, "SCHEMA")
            SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid), t.oid,

    Method create_trigger has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_trigger(table_name, proc_name, event, options = {})
        proc_name = "#{proc_name}"
        proc_name = "#{proc_name}()" unless proc_name.end_with?(')')
    
        for_each   = options[:for_each] || 'ROW'

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

      def triggers
        res = select_all <<-SQL
          SELECT n.nspname as schema,
                 c.relname as table,
                 t.tgname as trigger_name,

      Method functions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def functions
          pg_major = ::PgSaurus::Engine.pg_server_version[0]
          res = select_all <<-SQL
            SELECT n.nspname AS "Schema",
              p.proname AS "Name",

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

                def index_exists?(table_name, column_name, options = {})
                  column_names = Array.wrap(column_name)
                  index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, column: column_names)
        
                  # Always compare the index name

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

            def foreign_keys(table_name)
              namespace  = table_name.to_s.split('.').first
              table_name = table_name.to_s.split('.').last
        
              namespace  = if namespace == table_name

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

            def dump_triggers(stream)
              @connection.triggers.each do |trigger|
                statement = "  create_trigger '#{trigger.table}', '#{trigger.proc_name}', '#{trigger.event}', " \
                  "name: '#{trigger.name}', " \
                  "constraint: #{trigger.constraint ? :true : :false}, " \
          Severity: Minor
          Found in lib/pg_saurus/schema_dumper/trigger_methods.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 index_parts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def index_parts(index)
                is_json_index = index.columns.is_a?(String) && index.columns =~ /^(.+->.+)$/
          
                index_parts = [
                  index.columns.inspect,
          Severity: Minor
          Found in lib/core_ext/active_record/schema_dumper.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 foreign_keys has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def foreign_keys(table, stream)
              if (foreign_keys = @connection.foreign_keys(table)).any?
                add_foreign_key_statements = foreign_keys.map do |foreign_key|
          
                  from_table = if foreign_key.from_schema && foreign_key.from_schema != 'public'
          Severity: Minor
          Found in lib/pg_saurus/schema_dumper/foreign_key_methods.rb - About 1 hr to fix

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

                    def split_expression(expression)
                      result = []
                      parens = 0
                      buffer = ""
            
            

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

                def add_foreign_key(from_table, to_table, options = {})
                  exclude_index = (options.has_key?(:exclude_index) ? options.delete(:exclude_index) : false)
                  column        = options[:column] || foreign_key_column_for(to_table)
            
                  if index_exists?(from_table, column) && !exclude_index

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

                    def index_name(table_name, options) #:nodoc:
                      if Hash === options # legacy support
                        if options[:column]
                          column_names = Array.wrap(options[:column]).map {|c| expression_index_name(c)}
                          "index_#{table_name}_on_#{column_names * '_and_'}"

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

                    def add_index(table_name, column_name, options = {})
                      creation_method = options.delete(:concurrently) ? 'CONCURRENTLY' : nil
            
                      # Whether to skip the quoting of columns. Used only for expressions like JSON indexes in which
                      # the column is difficult to target for quoting.

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

              def triggers
                res = select_all <<-SQL
                  SELECT n.nspname as schema,
                         c.relname as table,
                         t.tgname as trigger_name,
            Severity: Minor
            Found in lib/pg_saurus/connection_adapters/postgresql_adapter/trigger_methods.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 tables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def tables(stream)
                super(stream)
            
                # Dump table and column comments
                @connection.tables.sort.each do |table_name|
            Severity: Minor
            Found in lib/pg_saurus/schema_dumper/comment_methods.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 functions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def functions
                pg_major = ::PgSaurus::Engine.pg_server_version[0]
                res = select_all <<-SQL
                  SELECT n.nspname AS "Schema",
                    p.proname AS "Name",
            Severity: Minor
            Found in lib/pg_saurus/connection_adapters/postgresql_adapter/function_methods.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 parse_function_volatility has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def parse_function_volatility(function_str)
                rows       = function_str.split("\n")
                lang_index = rows.index { |line| line =~ /LANGUAGE/ }
                def_index  = rows.index { |line| line =~ /AS \$function\$/ }
            
            
            Severity: Minor
            Found in lib/pg_saurus/connection_adapters/postgresql_adapter/function_methods.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 dump_comments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def dump_comments(table_name, stream)
                unless (comments = @connection.comments(table_name)).empty?
                  comment_statements = comments.map do |row|
                    column_name = row[0]
                    comment     = format_comment(row[1])
            Severity: Minor
            Found in lib/pg_saurus/schema_dumper/comment_methods.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