genediazjr/hapitodo

View on GitHub

Showing 5 of 13 total issues

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

exports.set = function (todo, next) {

    const requireId = todoSchema.requiredKeys('id').or('done', 'content');
    const err = requireId.validate(todo).error;
    let isUpdated = false;
Severity: Minor
Found in server/method/json/todoModel.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 set has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.set = function (todo, next) {

    const requireId = todoSchema.requiredKeys('id').or('done', 'content');
    const err = requireId.validate(todo).error;

Severity: Minor
Found in server/method/postgres/todoModel.js - About 1 hr to fix

    Function row has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.row = function (filter, next) {
    
        Postgres.connect(this.connectionString, (connErr, client, done) => {
    
            if (connErr) {
    Severity: Minor
    Found in server/method/postgres/todoModel.js - About 1 hr to fix

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

      exports.del = function (id, next) {
      
          const err = Joi.string().validate(id || null).error;
          let isDeleted = false;
      
      
      Severity: Minor
      Found in server/method/json/todoModel.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 row has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.row = function (filter, next) {
      
          const ids = Object.keys(this.todosDB);
          const todos = {
              totalTodoCount: ids.length,
      Severity: Minor
      Found in server/method/json/todoModel.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

      Severity
      Category
      Status
      Source
      Language