razum2um/lurker

View on GitHub

Showing 328 of 328 total issues

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

    def add_to_buffer(params, parent_accessors = [])
      params.each do |name, value|

        accessors = parent_accessors.clone << name
        if value.is_a?(Hash)
Severity: Minor
Found in lib/lurker/form_builder.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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def parse(payload)
          case payload
          when Lurker::Json::Schema
            payload
          when Hash
Severity: Minor
Found in lib/lurker/json/parser/typed_strategy.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 set_additional_properties_false_on has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def set_additional_properties_false_on(object)
          case object
          when Hash
            copy = object.dup

Severity: Minor
Found in lib/lurker/json/concerns/validatable.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

Function 12 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

},{"amdefine":17}],12:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
 * Copyright 2011 Mozilla Foundation and contributors
 * Licensed under the New BSD license. See LICENSE or:
Severity: Minor
Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

    Function parseProgramElements has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function parseProgramElements() {
            var sourceElement, sourceElements = [], token, directive, firstRestricted;
    
            while (index < length) {
                token = lookahead;
    Severity: Minor
    Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

      Function collectRegex has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function collectRegex() {
              var pos, loc, regex, token;
      
              skipComment();
      
      
      Severity: Minor
      Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

        Function parseSwitchStatement has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function parseSwitchStatement() {
                var discriminant, cases, clause, oldInSwitch, defaultFound;
        
                expectKeyword('switch');
        
        
        Severity: Minor
        Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

          Function relative has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.relative = function(from, to) {
            from = exports.resolve(from).substr(1);
            to = exports.resolve(to).substr(1);
          
            function trim(arr) {
          Severity: Minor
          Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

            Function parseUnaryExpression has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function parseUnaryExpression() {
                    var token, expr;
            
                    if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
                        return parsePostfixExpression();
            Severity: Minor
            Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

              Function uint8ToBase64 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function uint8ToBase64 (uint8) {
                      var i,
                          extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
                          output = "",
                          temp, length
              Severity: Minor
              Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                Function createState has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function createState(source, rootNode, transformOptions) {
                  return {
                    /**
                     * A tree representing the current local scope (and its lexical scope chain)
                     * Useful for tracking identifiers from parent scopes, etc.
                Severity: Minor
                Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                  Function scanOctalLiteral has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function scanOctalLiteral(prefix, start) {
                          var number, octal;
                  
                          if (isOctalDigit(prefix)) {
                              octal = true;
                  Severity: Minor
                  Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                    Function byteLength has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Buffer.byteLength = function (str, encoding) {
                      var ret
                      str = str + ''
                      switch (encoding || 'utf8') {
                        case 'hex':
                    Severity: Minor
                    Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                      Function parseImportDeclaration has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function parseImportDeclaration() {
                              var specifiers, kind, src;
                      
                              expectKeyword('import');
                              specifiers = [];
                      Severity: Minor
                      Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                        Function nextTick has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        process.nextTick = (function () {
                            var canSetImmediate = typeof window !== 'undefined'
                            && window.setImmediate;
                            var canPost = typeof window !== 'undefined'
                            && window.postMessage && window.addEventListener
                        Severity: Minor
                        Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                          Function isKeyword has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function isKeyword(id) {
                                  if (strict && isStrictModeReservedWord(id)) {
                                      return true;
                                  }
                          
                          
                          Severity: Minor
                          Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

                            Function SourceMapConsumer_eachMapping has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
                                  var context = aContext || null;
                                  var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
                            
                                  var mappings;
                            Severity: Minor
                            Found in lib/lurker/templates/javascripts/JSXTransformer.js - About 1 hr to fix

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

                                      if (length > 0) {
                                          if (typeof source[0] === 'undefined') {
                                              // Try first to convert to a string. This is good as fast path
                                              // for old IE which understands string indexing for string
                                              // literals only and not for string object.
                              Severity: Major
                              Found in lib/lurker/templates/javascripts/JSXTransformer.js and 1 other location - About 1 hr to fix
                              lib/lurker/templates/javascripts/JSXTransformer.js on lines 7847..7856

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

                              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

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

                                      if (length > 0) {
                                          if (typeof source[0] === 'undefined') {
                                              // Try first to convert to a string. This is good as fast path
                                              // for old IE which understands string indexing for string
                                              // literals only and not for string object.
                              Severity: Major
                              Found in lib/lurker/templates/javascripts/JSXTransformer.js and 1 other location - About 1 hr to fix
                              lib/lurker/templates/javascripts/JSXTransformer.js on lines 7739..7748

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

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

                                def example_from_schema(schema, parent=nil)
                                  if schema.nil?
                                    return nil
                                  end
                              
                              
                              Severity: Minor
                              Found in lib/lurker/presenters/endpoint_presenter.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

                              Severity
                              Category
                              Status
                              Source
                              Language