emiloberg/node-red-contrib-mopidy

View on GitHub

Showing 15 of 15 total issues

Function exports has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function(RED) {
    'use strict';
    function mopidyOutNode(n) {

        this.RED = RED;
Severity: Minor
Found in src/mopidy-out.js - About 1 day 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 exports has 158 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(RED) {
    'use strict';
    function mopidyOutNode(n) {

        this.RED = RED;
Severity: Major
Found in src/mopidy-out.js - About 6 hrs to fix

    Function mopidyOutNode has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function mopidyOutNode(n) {
    
            this.RED = RED;
            this.servers = servers;
            this.objectPath = objectPath;
    Severity: Major
    Found in src/mopidy-out.js - About 6 hrs to fix

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

              this.updateStatus = () => {
                  if (this.objectPath.get(this, 'mopidyServer.readyState', false) === true) {
                      this.status({ fill: 'green', shape: 'dot', text: this.RED._('mopidy-in.status.connected') });
                  } else {
                      this.status({ fill: 'grey', shape: 'dot', text: this.RED._('mopidy-in.status.not-connected') });
      Severity: Major
      Found in src/mopidy-in.js and 1 other location - About 4 hrs to fix
      src/mopidy-out.js on lines 29..35

      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 123.

      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

              this.updateStatus = () => {
                  if (this.objectPath.get(this, 'mopidyServer.readyState', false) === true) {
                      this.status({ fill: 'green', shape: 'dot', text: this.RED._('mopidy-out.status.connected') });
                  } else {
                      this.status({ fill: 'grey', shape: 'dot', text: this.RED._('mopidy-out.status.not-connected') });
      Severity: Major
      Found in src/mopidy-out.js and 1 other location - About 4 hrs to fix
      src/mopidy-in.js on lines 49..55

      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 123.

      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 invokeMethod has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              this.invokeMethod = (incomingMsg = {}) => {
                  if (typeof incomingMsg !== 'object') {
                      this.error(this.RED._('mopidy-out.validation.data-must-be-object'));
                      return;
                  }
      Severity: Major
      Found in src/mopidy-out.js - About 3 hrs to fix

        Function exports has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(RED) {
            'use strict';
            function mopidyInNode(n) {
        
                this.RED = RED;
        Severity: Minor
        Found in src/mopidy-in.js - About 1 hr to fix

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

              function mopidyInNode(n) {
          
                  this.RED = RED;
                  this.servers = servers;
                  this.objectPath = objectPath;
          Severity: Minor
          Found in src/mopidy-in.js - About 1 hr to fix

            Function exports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(RED) {
                'use strict';
                function mopidyInNode(n) {
            
                    this.RED = RED;
            Severity: Minor
            Found in src/mopidy-in.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

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

                                curServer.invokeMethod({method, params})
                                    .then((ret) => { this.send(objectAssign({payload: ret}, carryOnHostPort)); })
                                    .catch((err) => { this.error(this.RED._(err.msg, err.params)); });
            Severity: Major
            Found in src/mopidy-out.js and 1 other location - About 1 hr to fix
            src/mopidy-out.js on lines 139..141

            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 61.

            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

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

                                curServer.invokeMethod({method, params})
                                    .then((ret) => { this.send(objectAssign({payload: ret}, carryOnHostPort)); })
                                    .catch(() => { this.error(this.RED._('mopidy-out.errors.method-does-not-exist', { method }) ); })
            Severity: Major
            Found in src/mopidy-out.js and 1 other location - About 1 hr to fix
            src/mopidy-out.js on lines 122..124

            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 61.

            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 routeMethods has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    this.routeMethods = (req, res) => {
                        let tempServerNode = this.RED.nodes.getNode(req.params.nodeId);
            
                        if (tempServerNode === undefined || tempServerNode === null) {
                            res.status(404).json({
            Severity: Minor
            Found in src/mopidy-out.js - About 1 hr to fix

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

                          if (incomingMsg.hasOwnProperty('params')) {
                              if (typeof incomingMsg.params !== 'object') {
                                  this.error(this.RED._('mopidy-out.validation.params-must-be-object'));
                                  return;
                              }
              Severity: Minor
              Found in src/mopidy-out.js and 1 other location - About 30 mins to fix
              src/mopidy-out.js on lines 61..66

              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 45.

              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 too many return statements within this function.
              Open

                              return;
              Severity: Major
              Found in src/mopidy-out.js - About 30 mins to fix

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

                            if (incomingMsg.hasOwnProperty('method')) {
                                if (typeof incomingMsg.method !== 'string') {
                                    this.error(this.RED._('mopidy-out.validation.method-must-be-string'));
                                    return;
                                }
                Severity: Minor
                Found in src/mopidy-out.js and 1 other location - About 30 mins to fix
                src/mopidy-out.js on lines 67..72

                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 45.

                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

                Severity
                Category
                Status
                Source
                Language