meedan/check-bot

View on GitHub
helpers.js

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Function formatMessageFromData has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const formatMessageFromData = function(data) {

  // Build a list of verification statuses (core or custom) to be selected
  // Get the current status (label and color)

Severity: Major
Found in helpers.js - About 3 hrs to fix

    File helpers.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const config = require('./config.js'),
          Lokka = require('lokka').Lokka,
          Transport = require('lokka-transport-http').Transport,
          header = require('basic-auth-header'),
          request = require('request'),
    Severity: Minor
    Found in helpers.js - About 2 hrs to fix

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

      const formatMessageFromData = function(data) {
      
        // Build a list of verification statuses (core or custom) to be selected
        // Get the current status (label and color)
      
      
      Severity: Minor
      Found in helpers.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 executeMutation has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      const executeMutation = function(mutationQuery, vars, fail, done, token, callback, event, data) {
      Severity: Major
      Found in helpers.js - About 1 hr to fix

        Function saveAndReply has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        const saveAndReply = function(data, token, callback, mode, newMessage, attachments) {
        Severity: Minor
        Found in helpers.js - About 45 mins to fix

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

          const getIdentifier = function(text) {
            let identifier = null;
            // The identifier is different depending on the platform
            if (/WhatsApp Messenger/.test(text)) {
              identifier = text.match(/Phone Number:\s(.*)/)[1];
          Severity: Minor
          Found in helpers.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

          Function saveToRedisAndReplyToSlack has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          const saveToRedisAndReplyToSlack = function(redisKey, value, message, done, callback) {
          Severity: Minor
          Found in helpers.js - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status