redjazz96/liquidscript

View on GitHub

Showing 12 of 12 total issues

Class Javascript has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Javascript < Base
      module Literals

        BINOP_SWITCH = {
          "=="  => "===",
Severity: Minor
Found in lib/liquidscript/generator/javascript/literals.rb - About 3 hrs to fix

    Class ICR has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class ICR < Base
          module Literals
    
            def compile_number
              n = shift(:number)
    Severity: Minor
    Found in lib/liquidscript/compiler/icr/literals.rb - About 2 hrs to fix

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

              def generate_range(code, options = {}, norep = false)
                out = buffer
                a = norep ? code[1] : replace(code[1])
                b = norep ? code[2] : replace(code[2])
                out << "(function(a, b) {\n"                          <<
      Severity: Major
      Found in lib/liquidscript/generator/javascript/literals.rb and 1 other location - About 2 hrs to fix
      lib/liquidscript/generator/javascript/literals.rb on lines 66..82

      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

              def generate_erange(code, options = {}, norep = false)
                out = buffer
                a = norep ? code[1] : replace(code[1])
                b = norep ? code[2] : replace(code[2])
                out << "(function(a, b) {\n"                          <<
      Severity: Major
      Found in lib/liquidscript/generator/javascript/literals.rb and 1 other location - About 2 hrs to fix
      lib/liquidscript/generator/javascript/literals.rb on lines 47..63

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

              def compile_class
                delegate_if_class do
                  shift :class
                  name    = shift :identifier
                  inherit = nil
      Severity: Minor
      Found in lib/liquidscript/compiler/icr/classes.rb - About 1 hr to fix

        Method _compile_group has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def _compile_group(type, cond = false, continue = false)
                  shift type
        
                  if cond ||= block_given?
                    shift :lparen
        Severity: Minor
        Found in lib/liquidscript/compiler/icr/groups.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 _exec_context has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def _exec_context(code)
                  out = buffer
        
                  out << "#{indent}\"use strict\";\n" if code[:strict]
                  unless code.locals.empty?
        Severity: Minor
        Found in lib/liquidscript/generator/javascript/metas.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 out has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def out(v)
                if v.is_a?(Representable) || v.is_a?(Array)
                  @depth += 1
                  body = ["\n", " " * @depth, "(",
                    v.to_a.map {|d| out(d) }.compact.join(' '),
        Severity: Minor
        Found in lib/liquidscript/icr/sexp.rb - About 45 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 normalize_arguments has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def normalize_arguments(args)
                  hash = if args.last.is_a? Hash
                    args.pop.dup
                  else
                    {}
        Severity: Minor
        Found in lib/liquidscript/compiler/base/helpers.rb - About 45 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 _build_element has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def _build_element(body, options, opts, part)
                  k, v = part
        
                  type = if k.is_a? Symbol then k else k.type end
        
        
        Severity: Minor
        Found in lib/liquidscript/generator/javascript/objects.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 replace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def replace(code, options = {})
                  method_name = :"generate_#{code.type}"
        
                  if method(method_name).arity.abs == 1
                    send(method_name, code)
        Severity: Minor
        Found in lib/liquidscript/generator/base/replacements.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 lex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def lex(*args)
                  args.flatten!
                  to_lex = args.pop
        
                  context, body = if to_lex.is_a? Hash
        Severity: Minor
        Found in lib/liquidscript/scanner/base/lexer.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