etnbrd/flx-compiler

View on GitHub
test-set/timbits-master/lib/timbits.js

Summary

Maintainability
F
4 days
Test Coverage

File timbits.js has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Open


// load required modules
var fs = require('fs')
  , path = require('path')
  , querystring = require('querystring')
Severity: Minor
Found in test-set/timbits-master/lib/timbits.js - About 6 hrs to fix

    Function add has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    this.add = function(name, timbit, callback) {  
      timbits.log.info("Placing " + name + " in the box");
      timbits.box[name] = timbit;
      
      timbit.name = name;
    Severity: Major
    Found in test-set/timbits-master/lib/timbits.js - About 4 hrs to fix

      Function serve has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      this.serve = function(options) {
          
        /* configure options */
        for (var key in options) {
          value = options[key];
      Severity: Major
      Found in test-set/timbits-master/lib/timbits.js - About 3 hrs to fix

        Function generateTests has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Timbit.prototype.generateTests = function(alltests) {
          
          // create combination of required parameters
          var required = [];
          for (var name in this.params) {
        Severity: Minor
        Found in test-set/timbits-master/lib/timbits.js - About 1 hr to fix

          Function test has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Timbit.prototype.test = function(host, alltests, callback) {
            
            // generate dynamic list of test urls
            var tests = this.generateTests(alltests);
            
          Severity: Minor
          Found in test-set/timbits-master/lib/timbits.js - About 1 hr to fix

            Function render has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            Timbit.prototype.render = function(req, res, context) {
            
              // add caching headers
              res.setHeader("Cache-Control", "max-age=" + context.maxAge);
              res.setHeader("Edge-Control", "!no-store, max-age=" + context.maxAge);
            Severity: Minor
            Found in test-set/timbits-master/lib/timbits.js - 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 generateTests has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            Timbit.prototype.generateTests = function(alltests) {
              
              // create combination of required parameters
              var required = [];
              for (var name in this.params) {
            Severity: Minor
            Found in test-set/timbits-master/lib/timbits.js - 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

            Avoid deeply nested control flow statements.
            Open

                            if (result.passed) passed++; else failed++;
            Severity: Major
            Found in test-set/timbits-master/lib/timbits.js - About 45 mins to fix

              Function fetch has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              Timbit.prototype.fetch = function(req, res, context, options, callback) {
              Severity: Minor
              Found in test-set/timbits-master/lib/timbits.js - About 35 mins to fix

                Function add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                this.add = function(name, timbit, callback) {  
                  timbits.log.info("Placing " + name + " in the box");
                  timbits.box[name] = timbit;
                  
                  timbit.name = name;
                Severity: Minor
                Found in test-set/timbits-master/lib/timbits.js - 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

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

                      request(host + href, function(error, response, body) {
                        error = error || (response.statusCode === 200 ? '' : body);
                        results.push({
                          timbit: name,
                          href: href,
                Severity: Major
                Found in test-set/timbits-master/lib/timbits.js and 1 other location - About 4 hrs to fix
                test-set/timbits-master/lib/timbits.js on lines 557..569

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

                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

                      request.post(host + href, function(error, response, body) {
                        error = error || (response.statusCode === 200 ? '' : body);
                        results.push({
                          timbit: name,
                          href: href,
                Severity: Major
                Found in test-set/timbits-master/lib/timbits.js and 1 other location - About 4 hrs to fix
                test-set/timbits-master/lib/timbits.js on lines 542..554

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

                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

                      getTestValues(param.values, alltests).forEach(function(value) {
                        if (required.length === 0)
                          temp.push(name + "=" + value);
                        else
                          required.forEach(function(item) {
                Severity: Major
                Found in test-set/timbits-master/lib/timbits.js and 1 other location - About 3 hrs to fix
                test-set/timbits-master/lib/timbits.js on lines 490..497

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

                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

                        getTestValues(param.values, alltests).forEach(function(value) {
                          if (required.length === 0)
                            queries.push(name + "=" + value);
                          else
                            required.forEach(function(item) {
                Severity: Major
                Found in test-set/timbits-master/lib/timbits.js and 1 other location - About 3 hrs to fix
                test-set/timbits-master/lib/timbits.js on lines 467..474

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

                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

                There are no issues that match your filters.

                Category
                Status