ianperrin/MMM-Strava

View on GitHub

Showing 9 of 16 total issues

File node_helper.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @file node_helper.js
 *
 * @author ianperrin
 * @license MIT
Severity: Minor
Found in node_helper.js - About 3 hrs to fix

    Function getRadialDataPath has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getRadialDataPath(index, count, value) {
            const gap = 5;
            const startAngle = gap / 2 + index * (360 / count);
            const endAngle = startAngle + (360 - count * gap) / count;
            const radius = { inner: 109, outer: 109 + value * 100 };
    Severity: Major
    Found in MMM-Strava.js - About 2 hrs to fix

      `` has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      Module.register("MMM-Strava", {
          // Set the minimum MagicMirror module version for this module.
          requiresVersion: "2.2.0",
          // Default module config.
          defaults: {
      Severity: Minor
      Found in MMM-Strava.js - About 2 hrs to fix

        File MMM-Strava.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * @file MMM-Strava.js
         *
         * @author ianperrin
         * @license MIT
        Severity: Minor
        Found in MMM-Strava.js - About 2 hrs to fix

          Function summariseActivities has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              summariseActivities: function (moduleIdentifier, activityList) {
                  this.log("Summarising athlete activities for " + moduleIdentifier);
                  var moduleConfig = this.configs[moduleIdentifier].config;
                  var activitySummary = Object.create(null);
                  var activityName;
          Severity: Minor
          Found in node_helper.js - About 2 hrs to fix

            Function getAthleteActivities has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getAthleteActivities: async function (moduleIdentifier, accessToken, after) {
                    this.log("Getting athlete activities for " + moduleIdentifier + " after " + moment.unix(after).format("YYYY-MM-DD"));
                    const self = this;
                    var pageNum = 1;
                    var isPaging = true;
            Severity: Minor
            Found in node_helper.js - About 1 hr to fix

              Function socketNotificationReceived has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  socketNotificationReceived: function (notification, payload) {
                      var self = this;
                      this.log("Received notification: " + notification);
                      if (notification === "SET_CONFIG") {
                          // debug?
              Severity: Minor
              Found in node_helper.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

              Function summariseActivities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  summariseActivities: function (moduleIdentifier, activityList) {
                      this.log("Summarising athlete activities for " + moduleIdentifier);
                      var moduleConfig = this.configs[moduleIdentifier].config;
                      var activitySummary = Object.create(null);
                      var activityName;
              Severity: Minor
              Found in node_helper.js - About 55 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

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

                  handleApiError: function (moduleIdentifier, err) {
                      try {
                          // Strava-v3 errors - https://github.com/UnbounDev/node-strava-v3#error-handling
                          if (err) {
                              if (err.error && err.error.errors && err.error.errors[0].field === "access_token" && err.error.errors[0].code === "invalid") {
              Severity: Minor
              Found in node_helper.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