FunnelEnvy/optimizely-cli

View on GitHub

Showing 8 of 20 total issues

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

          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
              Severity
              Category
              Status
              Source
              Language