mmornati/ssh2-keeper

View on GitHub

Showing 8 of 11 total issues

Function search has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function search(query, verbose) {
  if (query.hostname) {
    log.info("Searching only using the Hostname 'cause it is unique into the database'");
    return database[config.server_collection].findOne({"hostname": query.hostname});
  } else {
Severity: Minor
Found in lib/utils.js - About 2 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 remove has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function remove(query, verbose) {
  if (query.hostname) {
    log.info("Removing %s server", query.hostname);
    var server = utils.search(query, verbose);
    log.info("Removing host from all related tags %s", server.tags);
Severity: Minor
Found in lib/operations.js - About 2 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 update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function update(server, verbose) {
  if (server.hostname && !utils.updateServer(server, verbose)) {
    log.error("Server %s is not present into DB", server.hostname);
  }

Severity: Minor
Found in lib/operations.js - About 2 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 remove has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function remove(query, verbose) {
  if (query.hostname) {
    log.info("Removing %s server", query.hostname);
    var server = utils.search(query, verbose);
    log.info("Removing host from all related tags %s", server.tags);
Severity: Minor
Found in lib/operations.js - About 1 hr to fix

Function convertHostToSSHCommand has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function convertHostToSSHCommand(hosts_list, verbose) {
  var ssh_commands = [];
  for (var j=0; j<hosts_list.length; j++) {
    var current_host = database[config.server_collection].find({hostname: hosts_list[j]});
    if (current_host && current_host.length > 0) {
Severity: Minor
Found in lib/utils.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 add has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function add(server, verbose) {
  if (!utils.updateServer(server, verbose)) {
    console.log("Saving...");
    database[config.server_collection].save(server);
  }
Severity: Minor
Found in lib/operations.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

Avoid deeply nested control flow statements.
Open

            if (server.hostname && !utils.updateServer(server, verbose)) {
              log.error("Error updating the server %s", db_tag[0].hostnames[j]);
            }
Severity: Major
Found in lib/operations.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        for (var k = 0; k < tag.hostnames.length; k++) {
          var db_host = database[config.server_collection].findOne({'hostname': tag.hostnames[k]});
          log.info(db_host);
          db_host.tags = removeTagFromHost(db_host, tag.tag);
          log.info(db_host);
Severity: Major
Found in lib/operations.js - About 45 mins to fix
Severity
Category
Status
Source
Language