Askrround/botly

View on GitHub

Showing 7 of 37 total issues

File botly_test.js has 1291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var expect = require('chai').expect;
var mockery = require('mockery');
var sinon = require('sinon');
var http = require('node-mocks-http');
var requireHelper = require('./util/requireHelper');
Severity: Major
Found in test/botly_test.js - About 3 days to fix

    File Botly.js has 605 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const util = require('util');
    const crypto = require('crypto');
    const EventEmitter = require('events').EventEmitter;
    Severity: Major
    Found in lib/Botly.js - About 1 day to fix

      Consider simplifying this complex logical expression.
      Open

          if (message.postback || (message.message && !message.message.is_echo && message.message.quick_reply)) {
              let postback = (message.postback && message.postback.payload) || message.message.quick_reply.payload;
              let ref = message.postback && message.postback.referral && message.postback.referral.ref;
              this.emit('postback', message.sender.id, message, postback, ref);
          }
      Severity: Critical
      Found in lib/Botly.js - About 1 hr to fix

        Function createListElement has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Botly.prototype.createListElement = function (options) {
            let element = {
                title: options.title
            };
            let buttons = options.buttons;
        Severity: Minor
        Found in lib/Botly.js - About 1 hr to fix

          Function getUserProfile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Botly.prototype.getUserProfile = function (options, callback) {
              let userId = options;
              let fields = [
                  USER_PROFILE_FIELD.FIRST_NAME,
                  USER_PROFILE_FIELD.LAST_NAME,
          Severity: Minor
          Found in lib/Botly.js - About 1 hr to fix

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

            Botly.prototype.createWebURLButton = function (title, url, heightRatio, supportExtension, fallbackURL, shareDisabled) {
            Severity: Minor
            Found in lib/Botly.js - About 45 mins to fix

              Function createListElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              Botly.prototype.createListElement = function (options) {
                  let element = {
                      title: options.title
                  };
                  let buttons = options.buttons;
              Severity: Minor
              Found in lib/Botly.js - About 25 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

              Severity
              Category
              Status
              Source
              Language