mozilla/webmaker.org

View on GitHub

Showing 59 of 111 total issues

Function likeClickCallback has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function likeClickCallback(e) {
      e.preventDefault();
      e.stopPropagation();
      var $this = $(this),
        makeID = $this.data('make-id'),
Severity: Minor
Found in public/js/pages/search.js - About 1 hr to fix

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

        function resultsCallback(err, data, total) {
          var oldMakes = searchResults.querySelectorAll('.make');
          var showingString = total ? ('Showing pg. ' + lastQuery.page + ' of ' + total) : 'No';
          if (oldMakes.length) {
            searchMasonry.remove(oldMakes);
    Severity: Minor
    Found in public/js/pages/editor.js - About 1 hr to fix

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

          apply: function (req, res, next) {
            var evidence = [req.body.evidence];
            var applicationSlug = req.body.applicationSlug;
      
            if (req.body.city) {
      Severity: Minor
      Found in routes/badges.js - About 1 hr to fix

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

        module.exports = function () {
          var make = require('../lib/makeapi').authenticated;
          return {
            like: function (req, res) {
              var id = req.body.makeID,
        Severity: Minor
        Found in routes/like.js - About 1 hr to fix

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

          module.exports = function () {
            var make = require('../lib/makeapi').authenticated;
            return {
              report: function (req, res) {
                var id = req.body.makeID,
          Severity: Minor
          Found in routes/report.js - About 1 hr to fix

            Function initTracking has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function initTracking() {
                    if (!session.mouseTrackingActive) {
                        session.mouseTrackingActive = true;
            
                        // grab the current viewport dimensions on load
            Severity: Minor
            Found in public/js/lib/jquery.powertip.js - About 1 hr to fix

              Function positionTipOnCursor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function positionTipOnCursor() {
                          // to support having fixed tooltips on the same page as cursor tooltips,
                          // where both instances are referencing the same tooltip element, we
                          // need to keep track of the mouse position constantly, but we should
                          // only set the tip location if a fixed tip is not currently open, a tip
              Severity: Minor
              Found in public/js/lib/jquery.powertip.js - About 1 hr to fix

                Function claim has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    claim: function (req, res, next) {
                      var codeQuery = {
                        system: env.get('BADGES_SYSTEM'),
                        badge: req.params.badge,
                        claimCode: req.body.claimcode
                Severity: Minor
                Found in routes/badges.js - About 1 hr to fix

                  Function sendSMS has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function sendSMS() {
                      sendSmsButton.attr('disabled', true);
                      var phoneNumber = phoneNumberInput.intlTelInput('getNumber', window.intlTelInputUtils.numberFormat.INTERNATIONAL);
                  
                      analytics.event('Click Send SMS Link for Beta App', {
                  Severity: Minor
                  Found in public/js/pages/install-app.js - About 1 hr to fix

                    Function issue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        issue: function (req, res, next) {
                          var apiFunction;
                          var query = {
                            system: env.get('BADGES_SYSTEM'),
                            badge: req.params.badge,
                    Severity: Minor
                    Found in routes/badges.js - About 1 hr to fix

                      Function sortByPriority has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          makeClient.sortByPriority = function (prefix, data) {
                            var sortedData = [],
                              duplicates = [],
                              priorityIndex,
                              regex = new RegExp('^' + prefix + '(\\d+)$');
                      Severity: Minor
                      Found in lib/makeapi.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (!isMouseOver(tipElement)) {
                                                        isDesynced = true;
                                                    }
                        Severity: Major
                        Found in public/js/lib/jquery.powertip.js - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                    if (config.supportLang.indexOf(item) !== -1 &&
                                      $scope.listLang.indexOf(item) !== 1 && $scope.listLang.length < 1 &&
                                      item.match(/^[a-z]{2}/) && config.lang.match(/^[a-z]{2}/) &&
                                      item.match(/^[a-z]{2}/)[0] !== config.lang.match(/^[a-z]{2}/)[0]) {
                                      $scope.listLang.push(item);
                          Severity: Major
                          Found in public/js/angular/controllers.js - About 40 mins to fix

                            Function computePlacementCoords has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    function computePlacementCoords(element, placement, tipWidth, tipHeight, offset) {
                            Severity: Minor
                            Found in public/js/lib/jquery.powertip.js - About 35 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return next();
                              Severity: Major
                              Found in routes/badges.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return next(errorHandlers.forbidden());
                                Severity: Major
                                Found in routes/badges.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return true;
                                  Severity: Major
                                  Found in public/js/pages/install-app.js - About 30 mins to fix

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

                                    module.exports = function () {
                                      var make = require('../lib/makeapi').authenticated;
                                      return {
                                        like: function (req, res) {
                                          var id = req.body.makeID,
                                    Severity: Minor
                                    Found in routes/like.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

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

                                    module.exports = function () {
                                      var make = require('../lib/makeapi').authenticated;
                                      return {
                                        report: function (req, res) {
                                          var id = req.body.makeID,
                                    Severity: Minor
                                    Found in routes/report.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