Showing 419 of 503 total issues

Method make_switch has 125 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  def make_switch(opts, block = nil)
    short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
    ldesc, sdesc, desc, arg = [], [], []
    default_style = Switch::NoArgument
    default_pattern = nil
Severity: Major
Found in stdlib/optparse.rb - About 4 hrs to fix

    Method _racc_yyparse_rb has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def _racc_yyparse_rb(recv, mid, arg, c_debug)
          action_table, action_check, action_default, action_pointer,
          _,             _,            _,              _,
          _,            _,            token_table,    _,
          _,            _,            * = arg
    Severity: Minor
    Found in stdlib/racc/parser.rb - About 4 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 optparse.rb has 1110 lines of code (exceeds 1000 allowed). Consider refactoring.
    Open

    class OptionParser
      OptionParser::Version = '0.1.1'
    
      # :stopdoc:
      NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
    Severity: Major
    Found in stdlib/optparse.rb - About 4 hrs to fix

      Method compile has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

            def compile
              scope.rescue_else_sexp = children[1..-1].detect { |sexp| sexp && sexp.type != :resbody }
              _has_rescue_handlers = false
      
              if handle_rescue_else_manually?
      Severity: Minor
      Found in lib/opal/nodes/rescue.rb - About 4 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

          if (value.$$is_array) {
            // A splatted array must be copied
            return value.slice();
          }
          else if (value['$respond_to?']('to_a', true)) {
      Severity: Major
      Found in opal/corelib/runtime.js and 1 other location - About 4 hrs to fix
      opal/corelib/runtime.js on lines 1800..1818

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

      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

          if (value.$$is_array) {
            return value;
          }
          else if (value['$respond_to?']('to_ary', true)) {
            var ary = value.$to_ary();
      Severity: Major
      Found in opal/corelib/runtime.js and 1 other location - About 4 hrs to fix
      opal/corelib/runtime.js on lines 1823..1842

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

      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 Integer has 108 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        def Integer(value, base = undefined, exception: true)
          %x{
            var i, str, base_digits;
      
            exception = $truthy(#{exception});
      Severity: Major
      Found in opal/corelib/kernel.rb - About 4 hrs to fix

        Method show_version has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

          def show_version(*pkgs)
            progname = ARGV.options.program_name
            result = false
            show = proc do |klass, cname, version|
              str = progname.to_s
        Severity: Minor
        Found in stdlib/optparse/version.rb - About 4 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 cover? has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

          def cover?(value)
            compare = ->(a, b) {
              a <=> b || 1
            }
        
        
        Severity: Minor
        Found in opal/corelib/range.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 compile has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile
                return push('[]') if children.empty?
        
                code, work = [], []
        
        
        Severity: Minor
        Found in lib/opal/nodes/array.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 plus has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

          def plus(path1, path2) # -> path # :nodoc:
            prefix2 = path2
            index_list2 = []
            basename_list2 = []
            while (r2 = chop_basename(prefix2))
        Severity: Minor
        Found in stdlib/pathname.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 one? has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          def one?(pattern = undefined, &block)
            count = 0
        
            if `pattern !== undefined`
              each do |*value|
        Severity: Minor
        Found in opal/corelib/enumerable.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 compile has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

              def compile
                code, work = [], []
        
                children.each do |current|
                  splat = current.type == :splat
        Severity: Minor
        Found in lib/opal/nodes/arglist.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 summarize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = '')
              sopts, lopts = [], [], nil
              @short.each { |s| sdone.fetch(s) { sopts << s }; sdone[s] = true } if @short
              @long.each { |s| ldone.fetch(s) { lopts << s }; ldone[s] = true } if @long
              return if sopts.empty? && lopts.empty? # completely hidden
        Severity: Minor
        Found in stdlib/optparse.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 candidate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def candidate(word)
            list = []
            case word
            when '-'
              long = short = true
        Severity: Minor
        Found in stdlib/optparse.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 tridiagonalize has 91 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

            def tridiagonalize
        
              #  This is derived from the Algol procedures tred2 by
              #  Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
              #  Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
        Severity: Major
        Found in stdlib/matrix/eigenvalue_decomposition.rb - About 3 hrs to fix

          Method prefork_reactor has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def prefork_reactor(rel_path, requires, autoloads, options)
                  prefork
          
                  processed = []
          
          
          Severity: Minor
          Found in lib/opal/builder_scheduler/prefork.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 source_map_name_for has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def source_map_name_for(sexp)
                case sexp.type
                when :top
                  case sexp.meta[:kind]
                  when :require
          Severity: Minor
          Found in lib/opal/fragment.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 initialize has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(options = nil)
                options ||= {}
          
                # Runner
                @runner_type    = options.delete(:runner)         || :nodejs
          Severity: Minor
          Found in lib/opal/cli.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 sample has 88 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

            def sample(count = undefined, options = undefined)
              return at ::Kernel.rand(`self.length`) if `count === undefined`
          
              if `options === undefined`
                if (o = ::Opal.coerce_to? count, ::Hash, :to_hash)
          Severity: Major
          Found in opal/corelib/array.rb - About 3 hrs to fix
            Severity
            Category
            Status
            Source
            Language