sockethub/sockethub

View on GitHub

Showing 42 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              console.log('public url: ' + config.get('public:host') + ':' + config.get('public:port')
                          + config.get('public:path'));
            Severity: Minor
            Found in packages/sockethub/src/bootstrap/init.ts and 1 other location - About 50 mins to fix
            packages/sockethub/src/bootstrap/init.ts on lines 30..31

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 51.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              console.log('sockethub: ' + config.get('service:host') + ':' + config.get('service:port')
                          + config.get('service:path'));
            Severity: Minor
            Found in packages/sockethub/src/bootstrap/init.ts and 1 other location - About 50 mins to fix
            packages/sockethub/src/bootstrap/init.ts on lines 38..39

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 51.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  defaultEnvParams(
                    process.env.HOST || nconf.get('service:host'),
                    process.env.PORT || nconf.get('service:port'),
                    'service'
                  );
              Severity: Minor
              Found in packages/sockethub/src/config.ts and 1 other location - About 40 mins to fix
              packages/sockethub/src/config.ts on lines 56..60

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  defaultEnvParams(
                    process.env.REDIS_HOST || nconf.get('redis:host'),
                    process.env.REDIS_PORT || nconf.get('redis:port'),
                    'redis'
                  );
              Severity: Minor
              Found in packages/sockethub/src/config.ts and 1 other location - About 40 mins to fix
              packages/sockethub/src/config.ts on lines 50..54

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Line length
              Open

              *For more info on configuration options, see the [Sockethub README](packages/sockethub/README.md#environment-variables)* section on environment variables.*
              Severity: Info
              Found in README.md by markdownlint

              MD013 - Line length

              Tags: line_length

              Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

              This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

              This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

              You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

              Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

              Line length
              Open

              Using [ActivityStream](http://activitystrea.ms/) (AS) objects to pass messages to and from the web app, Sockethub acts as a smart proxy server/agent, which can maintain state, and connect to sockets, endpoints and networks that would otherwise be restricted from an application running in the browser.
              Severity: Info
              Found in packages/sockethub/README.md by markdownlint

              MD013 - Line length

              Tags: line_length

              Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

              This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

              This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

              You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

              Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

              Line length
              Open

              This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
              Severity: Info
              Found in CODE_OF_CONDUCT.md by markdownlint

              MD013 - Line length

              Tags: line_length

              Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

              This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

              This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

              You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

              Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

              Emphasis used instead of a header
              Open

              **For more information on Sockethub see the [Sockethub README](packages/sockethub/README.md)**
              Severity: Info
              Found in README.md by markdownlint

              MD036 - Emphasis used instead of a header

              Tags: headers, emphasis

              Parameters: punctuation (string; default ".,;:!?")

              Aliases: no-emphasis-as-header

              This check looks for instances where emphasized (i.e. bold or italic) text is used to separate sections, where a header should be used instead:

              **My document**
              
              Lorem ipsum dolor sit amet...
              
              _Another section_
              
              Consectetur adipiscing elit, sed do eiusmod.

              To fix this, use markdown headers instead of emphasized text to denote sections:

              # My document
              
              Lorem ipsum dolor sit amet...
              
              ## Another section
              
              Consectetur adipiscing elit, sed do eiusmod.

              Note: this rule looks for single line paragraphs that consist entirely of emphasized text. It won't fire on emphasis used within regular text, multi-line emphasized paragraphs, and paragraphs ending in punctuation. Similarly to rule MD026, you can configure what characters are recognized as punctuation.

              Line length
              Open

              Originally inspired as a sister project to [RemoteStorage](https://remotestorage.io), and assisting in the development of [unhosted](http://unhosted.org) and [noBackend](http://nobackend.org) applications, Sockethub's functionality can also fit into a more traditional development stack, removing the need for custom code to handle various protocol specifics at the application layer.
              Severity: Info
              Found in packages/sockethub/README.md by markdownlint

              MD013 - Line length

              Tags: line_length

              Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

              This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

              This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

              You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

              Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

              Emphasis used instead of a header
              Open

              ***OR***
              Severity: Info
              Found in packages/sockethub/README.md by markdownlint

              MD036 - Emphasis used instead of a header

              Tags: headers, emphasis

              Parameters: punctuation (string; default ".,;:!?")

              Aliases: no-emphasis-as-header

              This check looks for instances where emphasized (i.e. bold or italic) text is used to separate sections, where a header should be used instead:

              **My document**
              
              Lorem ipsum dolor sit amet...
              
              _Another section_
              
              Consectetur adipiscing elit, sed do eiusmod.

              To fix this, use markdown headers instead of emphasized text to denote sections:

              # My document
              
              Lorem ipsum dolor sit amet...
              
              ## Another section
              
              Consectetur adipiscing elit, sed do eiusmod.

              Note: this rule looks for single line paragraphs that consist entirely of emphasized text. It won't fire on emphasis used within regular text, multi-line emphasized paragraphs, and paragraphs ending in punctuation. Similarly to rule MD026, you can configure what characters are recognized as punctuation.

              Bare URL used
              Open

              https://www.contributor-covenant.org/faq
              Severity: Info
              Found in CODE_OF_CONDUCT.md by markdownlint

              MD034 - Bare URL used

              Tags: links, url

              Aliases: no-bare-urls

              This rule is triggered whenever a URL is given that isn't surrounded by angle brackets:

              For more information, see http://www.example.com/.

              To fix this, add angle brackets around the URL:

              For more information, see <http:></http:>.

              Rationale: Without angle brackets, the URL isn't converted into a link in many markdown parsers.

              Note: if you do want a bare URL without it being converted into a link, enclose it in a code block, otherwise in some markdown parsers it will be converted:

              `http://www.example.com`

              Lists should be surrounded by blank lines
              Open

              * HOST
              Severity: Info
              Found in packages/sockethub/README.md by markdownlint

              MD032 - Lists should be surrounded by blank lines

              Tags: bullet, ul, ol, blank_lines

              Aliases: blanks-around-lists

              This rule is triggered when lists (of any kind) are either not preceded or not followed by a blank line:

              Some text
              * Some
              * List
              
              1. Some
              2. List
              Some text

              To fix this, ensure that all lists have a blank line both before and after (except where the block is at the beginning or end of the document):

              Some text
              
              * Some
              * List
              
              1. Some
              2. List
              
              Some text

              Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse lists that don't have blank lines before and after them.

              Note: List items without hanging indents are a violation of this rule; list items with hanging indents are okay:

              * This is
              not okay
              
              * This is
                okay
              Severity
              Category
              Status
              Source
              Language