sockethub/sockethub

View on GitHub

Showing 8 of 48 total issues

Function platformLoad has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function platformLoad(moduleList) {
  // load platforms from package.json
  const rx = new RegExp('^sockethub-platform-', 'i');
  const platforms = new Map();
  log('finding and registering platforms from package list');
Severity: Minor
Found in packages/sockethub/src/bootstrap/platforms.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 __registerSocketIOHandlers has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  SockethubClient.prototype.__registerSocketIOHandlers = function () {
    let storedCredentials     = new Map(),
        storedActivityObjects = new Map(),
        storedConnects        = new Map(),
        storedJoins           = new Map();
Severity: Major
Found in packages/sockethub/src/js/client.js - About 2 hrs to fix

    Function platformLoad has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function platformLoad(moduleList) {
      // load platforms from package.json
      const rx = new RegExp('^sockethub-platform-', 'i');
      const platforms = new Map();
      log('finding and registering platforms from package list');
    Severity: Minor
    Found in packages/sockethub/src/bootstrap/platforms.js - About 1 hr to fix

      Function constructor has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor() {
          log('initializing config');
          // assign config loading priorities (command-line, environment, cfg, defaults)
          nconf.argv({
            'port': {
      Severity: Minor
      Found in packages/sockethub/src/config.ts - About 1 hr to fix

        Function emit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            this.socket.emit = (channel, content) => {
              if (typeof channel !== 'string') {
                throw new Error('emit function requires a channel name [string] to be specified as the'
                  + ' first parameter.');
              }
        Severity: Minor
        Found in packages/sockethub/src/js/client.js - About 1 hr to fix

          Function incomingConnection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private incomingConnection(socket: Socket) {
              const sessionLog = debug('sockethub:core:' + socket.id), // session-specific debug messages
                    sessionSecret = crypto.randToken(16),
                    // store instance is session-specific
                    store = getSessionStore(this.parentId, this.parentSecret1, socket.id, sessionSecret),
          Severity: Minor
          Found in packages/sockethub/src/sockethub.ts - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (p.schema.credentials) {
                        // register the platforms credentials schema
                        types.push('credentials');
                        tv4.addSchema(`http://sockethub.org/schemas/v0/context/${platformName}/credentials`,
                          p.schema.credentials);
            Severity: Major
            Found in packages/sockethub/src/bootstrap/platforms.js - About 45 mins to fix

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

              function platformIsAccepted(platformName) {
                let willLoad = false;
                if (whitelist.length > 0) {
                  if (whitelist.indexOf(platformName) >= 0) {
                    willLoad = true;
              Severity: Minor
              Found in packages/sockethub/src/bootstrap/platforms.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