jonatas/fast

View on GitHub

Showing 15 of 15 total issues

File fast.rb has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fileutils'
require 'astrolabe/builder'
require_relative 'fast/rewriter'

# suppress output to avoid parser gem warnings'
Severity: Minor
Found in lib/fast.rb - About 7 hrs to fix

    Method run! has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def run!
          raise 'pry and parallel options are incompatible :(' if @parallel && @pry
    
          if @help || @files.empty? && @pattern.nil?
            puts option_parser.help
    Severity: Minor
    Found in lib/fast/cli.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 option_parser has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def option_parser # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
          @option_parser ||= OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
            opts.banner = 'Usage: fast expression <files> [options]'
            opts.on('-d', '--debug', 'Debug fast engine') do
              @debug = true
    Severity: Major
    Found in lib/fast/cli.rb - About 2 hrs to fix

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

          def search(pattern, node, *args)
            if (match = match?(pattern, node, *args))
              yield node, match if block_given?
              match != true ? [node, match] : [node]
            else
      Severity: Minor
      Found in lib/fast.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 experiment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def experiment(file, name, search, replacement)
        ast = Fast.ast_from_file(file)
      
        results = Fast.search(ast, search)
        unless results.empty?
      Severity: Minor
      Found in examples/experimental_replacement.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 report has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def report(result, show_link: false, show_permalink: false, show_sexp: false, file: nil, headless: false, bodyless: false, colorize: true) # rubocop:disable Metrics/ParameterLists
          if file
            line = result.loc.expression.line if result.is_a?(Parser::AST::Node)
            if show_link
              puts(result.link)
      Severity: Minor
      Found in lib/fast/cli.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 partial_replace has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def partial_replace(*indices)
            replacement = experiment.replacement
            new_content = Fast.replace_file experiment.expression, @file do |node, *captures|
              if indices.nil? || indices.empty? || indices.include?(match_index)
                if replacement.parameters.length == 1
      Severity: Minor
      Found in lib/fast/experiment.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse
            case (token = next_token)
            when '(' then parse_until_peek(')')
            when '{' then Any.new(parse_until_peek('}'))
            when '[' then All.new(parse_until_peek(']'))
      Severity: Minor
      Found in lib/fast.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 highlight has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def highlight(node, show_sexp: false, colorize: true, sql: false)
          output =
            if node.respond_to?(:loc) && !show_sexp
              wrap_source_range(node).source
            else
      Severity: Minor
      Found in lib/fast/cli.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 clean_structure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def clean_structure(stmt)
            res_hash = stmt.map do |key, value|
              value = clean_structure(value) if value.is_a?(Hash)
              value = value.map(&Fast::SQL.method(:clean_structure)) if value.is_a?(Array)
              value = nil if [{}, [], "", :SETOP_NONE, :LIMIT_OPTION_DEFAULT, false].include?(value)
      Severity: Minor
      Found in lib/fast/sql.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 sql_tree_to_ast has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def sql_tree_to_ast(obj, source_buffer: nil, source_map: nil)
            recursive = -> (e) { sql_tree_to_ast(e, source_buffer: source_buffer, source_map: source_map.dup) }
            case obj
            when Array
              obj.map(&recursive).flatten.compact
      Severity: Minor
      Found in lib/fast/sql.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 capture has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def capture(pattern, node)
            if (match = match?(pattern, node))
              match == true ? node : match
            else
              node.each_child_node
      Severity: Minor
      Found in lib/fast.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(statement, buffer_name: "(sql)")
            return [] if statement.nil?
            source_buffer = SQL::SourceBuffer.new(buffer_name, source: statement)
            tree = PgQuery.parse(statement).tree
            first, *, last = source_buffer.tokens
      Severity: Minor
      Found in lib/fast/sql.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 match_recursive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def match_recursive(expression, node)
            case expression
            when Proc then expression.call(node)
            when Find then expression.match?(node)
            when Symbol then compare_symbol_or_head(expression, node)
      Severity: Minor
      Found in lib/fast.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def run
            while (combinations = build_combinations).any?
              if combinations.size > 1000
                puts "Ignoring #{@file} because it has #{combinations.size} possible combinations"
                break
      Severity: Minor
      Found in lib/fast/experiment.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