jesusfer/node-telegram-bot-emtbus

View on GitHub

Showing 9 of 9 total issues

File emtBot.js has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (c) 2018 Jesús Fernández <jesus@nublar.net>
// MIT License
'use strict';

const settings = require('./settings.js');
Severity: Minor
Found in src/emtBot.js - About 6 hrs to fix

    Function buildStop has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    const buildStop = function (rawStop) {
        return new P(function (resolve, reject) {
            let newStop = {};
            let nodeId = _.get(rawStop, 'Node[0]', -1);
            let stopId = _.get(rawStop, 'stopId', -1);
    Severity: Minor
    Found in src/emtBot.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 findStops has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    const findStops = function (query, location, exact = false) {
        return new P(function (resolve, reject) {
            let isEmptyQuery = false;
            let isLocationQuery = false;
            let isNaNQuery = false;
    Severity: Minor
    Found in src/emtBot.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 buildStop has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const buildStop = function (rawStop) {
        return new P(function (resolve, reject) {
            let newStop = {};
            let nodeId = _.get(rawStop, 'Node[0]', -1);
            let stopId = _.get(rawStop, 'stopId', -1);
    Severity: Major
    Found in src/emtBot.js - About 2 hrs to fix

      Function findStops has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const findStops = function (query, location, exact = false) {
          return new P(function (resolve, reject) {
              let isEmptyQuery = false;
              let isLocationQuery = false;
              let isNaNQuery = false;
      Severity: Major
      Found in src/emtBot.js - About 2 hrs to fix

        Function renderStop has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const renderStop = function (stop) {
            return new P(function (resolve) {
                let arriving = 'Sin estimaciones';
                if (stop.arriving.length > 0) {
                    let widths = getColumnWidths(stop, columns);
        Severity: Minor
        Found in src/emtBot.js - About 1 hr to fix

          Function processRefresh has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const processRefresh = function (request, stopId) {
              if (_.isNaN(+stopId)) {
                  debug('Bad refresh stopId');
                  return;
              }
          Severity: Minor
          Found in src/emtBot.js - About 1 hr to fix

            Function getStopLocation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getStopLocation = function (stopId, line, direction) {
                debug(`Getting location for stop ${stopId} with line ${line} and direction ${direction}`);
                let cachedStop = stopCache.filter(function (o) {
                    return o.Node == stopId;
                })[0];
            Severity: Minor
            Found in src/emtBot.js - About 1 hr to fix

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

              const getArrivingBuses = function (stop) {
                  // Return a promise
                  return new P(function (resolve) {
                      EMTAPI.getIncomingBusesToStop(stop.Id)
                          .then(function (arriving) {
              Severity: Minor
              Found in src/emtBot.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

              Severity
              Category
              Status
              Source
              Language