Showing 419 of 503 total issues

Method thrower has 69 lines of code (exceeds 30 allowed). Consider refactoring.
Open

        def thrower(type, value = nil)
          case type
          when :return
            thrower_closure = select_closure(DEF, break_after: MODULE | TOP)
            last_closure = select_closure(JS_FUNCTION)
Severity: Major
Found in lib/opal/nodes/closure.rb - About 2 hrs to fix

    Method slice! has 68 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      def slice!(index, length = undefined)
        `$deny_frozen_access(self)`
    
        result = nil
    
    
    Severity: Major
    Found in opal/corelib/array.rb - About 2 hrs to fix

      Method from_string has 67 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        def self.from_string(str)
          %x{
            var re = /[+-]?[\d_]+(\.[\d_]+)?(e\d+)?/,
                match = str.match(re),
                real, imag, denominator;
      Severity: Major
      Found in opal/corelib/complex.rb - About 2 hrs to fix

        Method next has 67 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

          def next
            %x{
              var i = self.length;
              if (i === 0) {
                return '';
        Severity: Major
        Found in opal/corelib/string.rb - About 2 hrs to fix

          Method fill has 66 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

            def fill(*args, &block)
              %x{
                $deny_frozen_access(self);
          
                var i, length, value;
          Severity: Major
          Found in opal/corelib/array.rb - About 2 hrs to fix

            Method [] has 66 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

              def [](index, length = undefined)
                %x{
                  var size = self.length, exclude, range;
            
                  if (index.$$is_range) {
            Severity: Major
            Found in opal/corelib/string.rb - About 2 hrs to fix

              Method reduce_to_hessenberg has 65 lines of code (exceeds 30 allowed). Consider refactoring.
              Open

                  def reduce_to_hessenberg
                    #  This is derived from the Algol procedures orthes and ortran,
                    #  by Martin and Wilkinson, Handbook for Auto. Comp.,
                    #  Vol.ii-Linear Algebra, and the corresponding
                    #  Fortran subroutines in EISPACK.
              Severity: Major
              Found in stdlib/matrix/eigenvalue_decomposition.rb - About 2 hrs to fix

                Method returns has 62 lines of code (exceeds 30 allowed). Consider refactoring.
                Open

                    def returns(sexp)
                      return returns s(:nil) unless sexp
                
                      case sexp.type
                      when :undef
                Severity: Major
                Found in lib/opal/compiler.rb - About 2 hrs to fix

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

                      def join(*paths)
                        if paths.empty?
                          return ''
                        end
                        result = ''
                  Severity: Minor
                  Found in opal/corelib/file.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 on_send has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def on_send(node)
                          recv, meth, *args = *node
                          if recv && recv.type == :send
                            recv_of_recv, meth_of_recv, _ = *recv
                            if meth_of_recv == :JS
                  Severity: Minor
                  Found in lib/opal/rewriters/dot_js_syntax.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 a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def **(other)
                      case other
                      when Integer
                        x = self
                        if other <= 0
                  Severity: Minor
                  Found in stdlib/matrix.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 load has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def load(filename = nil)
                      unless filename
                        basename = File.basename($0, '.*')
                        begin
                          return true if load(File.expand_path(basename, '~/.options'))
                  Severity: Minor
                  Found in stdlib/optparse.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 gsub has 61 lines of code (exceeds 30 allowed). Consider refactoring.
                  Open

                    def gsub(pattern, replacement = undefined, &block)
                      %x{
                        if (replacement === undefined && block === nil) {
                          return #{enum_for :gsub, pattern};
                        }
                  Severity: Major
                  Found in opal/corelib/string.rb - About 2 hrs to fix

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

                                    p = x * @h[i][k] + y * @h[i][k+1]
                                    if (notlast)
                                      p += z * @h[i][k+2]
                                      @h[i][k+2] = @h[i][k+2] - p * r
                                    end
                    Severity: Major
                    Found in stdlib/matrix/eigenvalue_decomposition.rb and 1 other location - About 2 hrs to fix
                    stdlib/matrix/eigenvalue_decomposition.rb on lines 712..718

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

                    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

                                    p = x * @v[i][k] + y * @v[i][k+1]
                                    if (notlast)
                                      p += z * @v[i][k+2]
                                      @v[i][k+2] = @v[i][k+2] - p * r
                                    end
                    Severity: Major
                    Found in stdlib/matrix/eigenvalue_decomposition.rb and 1 other location - About 2 hrs to fix
                    stdlib/matrix/eigenvalue_decomposition.rb on lines 700..706

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

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

                      def **(other)
                        if other == 0
                          return ::Complex.new(1, 0)
                        end
                    
                    
                    Severity: Minor
                    Found in opal/corelib/complex.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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def **(other)
                        case other
                        when ::Integer
                          if self == 0 && other < 0
                            ::Float::INFINITY
                    Severity: Minor
                    Found in opal/corelib/rational.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 compile_masgn has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def compile_masgn(lhs_items, array, len = nil)
                            pre_splat  = lhs_items.take_while { |child| child.type != :splat }
                            post_splat = lhs_items.drop(pre_splat.size)
                    
                            pre_splat.each_with_index do |child, idx|
                    Severity: Minor
                    Found in lib/opal/nodes/masgn.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 compile has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def compile
                            test_code = js_truthy(test)
                    
                            @redo_var = scope.new_temp if uses_redo?
                    
                    
                    Severity: Minor
                    Found in lib/opal/nodes/while.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 could_become_switch_branch? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def could_become_switch_branch?(body)
                            if !body
                              return true
                            elsif body.type != :if
                              if valid_switch_body?(body)
                    Severity: Minor
                    Found in lib/opal/nodes/if.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

                    Severity
                    Category
                    Status
                    Source
                    Language