FunnelEnvy/optimizely-cli

View on GitHub

Showing 20 of 20 total issues

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

  return client.updateVariation(varArgs).then(function(variationAttrs) {
    logger.log("info", "updated remote variation: " + variationAttrs.id);
  }, function(error) {
    logger.log("error", error);
  }).catch(function(e) {
Severity: Major
Found in lib/variation.js and 1 other location - About 3 hrs to fix
lib/experiment.js on lines 112..119

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

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

  return client.updateExperiment(expArgs).then(function(experimentAttrs) {
    logger.log("info", "updated remote experiment: " + experimentAttrs.id);
  }, function(error) {
    logger.log("error", error);
  }).catch(function(e) {
Severity: Major
Found in lib/experiment.js and 1 other location - About 3 hrs to fix
lib/variation.js on lines 101..108

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

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

            case "token":
                require("./set-" + name + "")()
                .then(function(token){
                    d.resolve(token);
                })
Severity: Major
Found in lib/read-config.js and 1 other location - About 2 hrs to fix
lib/read-config.js on lines 22..31

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

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

            case "project":
                require("./set-" + name + "")()
                .then(function(token){
                    d.resolve(token);
                })
Severity: Major
Found in lib/read-config.js and 1 other location - About 2 hrs to fix
lib/read-config.js on lines 12..21

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

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

Function exports has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function(varPath, port, program) {
  //Start Server
  var app = express();
  var localController;

Severity: Minor
Found in lib/commands/host.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 exports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(varPath, port, program) {
  //Start Server
  var app = express();
  var localController;

Severity: Minor
Found in lib/commands/host.js - About 1 hr to fix

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

    function Files(attributes, baseDir, assets) {
      Files.super_.call(this, attributes, baseDir);
      //get HTML files in the experiment folder
      this.filenames = fs.readdirSync(baseDir);
      
    Severity: Minor
    Found in lib/files.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 exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(name){
        var d = q.defer();
        try{
            var result = fs.readFileSync(".optcli/" + name, {encoding:"utf-8"});
            d.resolve(result);
    Severity: Minor
    Found in lib/read-config.js - About 1 hr to fix

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

      module.exports = function(folder) {
        //find the variation
        var varPath = path.resolve(process.cwd(), folder);
        var variation = new Variation({}, varPath);
        variation.loadFromFile();
      Severity: Minor
      Found in lib/commands/push-variation.js - About 1 hr to fix

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

        function Files(attributes, baseDir, assets) {
          Files.super_.call(this, attributes, baseDir);
          //get HTML files in the experiment folder
          this.filenames = fs.readdirSync(baseDir);
          
        Severity: Minor
        Found in lib/files.js - About 1 hr to fix

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

            return client.createExperiment(expArgs).then(function(experimentAttrs) {
                //update the id
                self.attributes.id = experimentAttrs.id;
                self.saveAttributes();
                logger.log("info", "created remote experiment: " + experimentAttrs.id);
          Severity: Major
          Found in lib/experiment.js and 1 other location - About 1 hr to fix
          lib/variation.js on lines 65..70

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

          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

            return client.createVariation(varArgs).then(function(variationAttrs) {
              //update the id
              self.attributes.id = variationAttrs.id;
              self.saveAttributes();
              logger.log("info", "created remote variation: " + variationAttrs.id);
          Severity: Major
          Found in lib/variation.js and 1 other location - About 1 hr to fix
          lib/experiment.js on lines 91..96

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

          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

          Function createRemote has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Variation.prototype.createRemote = function(client, remote) {
            //assume assets are in experiment.baseDir
            var assets = new Assets({}, path.normalize(this.baseDir + "/.."));
            if (assets.JSONFileExists()) {
              logger.log("info", "assets file found, loading");
          Severity: Minor
          Found in lib/variation.js - About 1 hr to fix

            Function LocalController has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function LocalController(variation, port) {
              this.variation = variation;
              //assume the directory above the variation
              //maybe move this to Experiment?
              this.experiment = new Experiment({}, path.normalize(variation.baseDir + "/.."));
            Severity: Minor
            Found in lib/server/controller.js - About 1 hr to fix

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

                varArgs['js_component'] = String(ejs.render(this.getJS(), {
                  locals: {
                    assets: assets.attributes,
                    files: files.data
                  }
              Severity: Major
              Found in lib/variation.js and 1 other location - About 1 hr to fix
              lib/variation.js on lines 56..61

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

              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

                varArgs['js_component'] = String(ejs.render(this.getJS(), {
                  locals: {
                    assets: assets.attributes,
                    files: files.data
                  }
              Severity: Major
              Found in lib/variation.js and 1 other location - About 1 hr to fix
              lib/variation.js on lines 93..98

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

              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

              Variation.prototype.saveAttributes = function() {
                fileUtil.writeJSON(path.join(this.baseDir, Variation.JSON_FILE_NAME), this.attributes);
              }
              Severity: Minor
              Found in lib/variation.js and 1 other location - About 55 mins to fix
              lib/experiment.js on lines 122..125

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

              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

              Experiment.prototype.saveAttributes = function() {
                fileUtil.writeJSON(path.join(this.baseDir, Experiment.JSON_FILE_NAME), this
                  .attributes);
              }
              Severity: Minor
              Found in lib/experiment.js and 1 other location - About 55 mins to fix
              lib/variation.js on lines 111..113

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

              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 (success) {
                  logger.log("info", "created variation " + description + "in folder " + folder);
                } else {
                  logger.log("error", "failed to create variation");
                }
              Severity: Minor
              Found in lib/commands/create-variation.js and 1 other location - About 35 mins to fix
              lib/commands/create-experiment.js on lines 19..23

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

              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 (success) {
                  logger.log("info", "created experiment \"" + description + "\" in folder " + folder);
                } else {
                  logger.log("error", "failed to create experiment");
                }
              Severity: Minor
              Found in lib/commands/create-experiment.js and 1 other location - About 35 mins to fix
              lib/commands/create-variation.js on lines 12..16

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

              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

              Severity
              Category
              Status
              Source
              Language