NaturalIntelligence/Stubmatic

View on GitHub
index.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function buildServerOptions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function buildServerOptions(args) {
    var options = {};
    for (var i = 2; i < args.length; i++) {
        if (args[i].indexOf("-") === 0) {
            var key = args[i];
Severity: Minor
Found in index.js - About 3 hrs 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 buildServerOptions has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function buildServerOptions(args) {
    var options = {};
    for (var i = 2; i < args.length; i++) {
        if (args[i].indexOf("-") === 0) {
            var key = args[i];
Severity: Minor
Found in index.js - About 1 hr to fix

    Function validateSyntax has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function validateSyntax(fileName) {
        try {
            if (fileName.endsWith(".json")) {
                require('jsonlint').parse(fs.readFileSync(fileName, {
                    encoding: 'utf-8'
    Severity: Minor
    Found in index.js - 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

    Avoid deeply nested control flow statements.
    Open

                    if (key === '--port' || key === '-p') {
                        key = '-p';
                    } else if (key === '--config' || key === '-c') {
                        key = '-c';
                    } else if (key === '--host' || key === '-P' || key === '--mutualSSL') {
    Severity: Major
    Found in index.js - About 45 mins to fix

      Function cli has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function cli(args) {
          if (args[2] === "--help" || args[2] === "-h") {
              console.log(fs.readFileSync(__dirname + "/man/stubmatic.1", 'utf-8'));
          } else if (args[2] === "--version") {
              console.log(require(__dirname + "/package.json").version);
      Severity: Minor
      Found in index.js - 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

      There are no issues that match your filters.

      Category
      Status