mozilla/webmaker.org

View on GitHub

Showing 59 of 111 total issues

Function computePlacementCoords has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function computePlacementCoords(element, placement, tipWidth, tipHeight, offset) {
            var placementBase = placement.split('-')[0], // ignore 'alt' for corners
                coords = new CSSCoordinates(),
                position;

Severity: Major
Found in public/js/lib/jquery.powertip.js - About 2 hrs to fix

    Function navigation has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return function navigation() {
        var $mainNavContainer = $('#main-navigation-container');
        var lang = $('html').attr('lang') || 'en-US';
    
        var $expandedNavTriggers = $('.navbar-toggle');
    Severity: Major
    Found in public/js/base/navigation.js - About 2 hrs to fix

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

            function resultsCallback(err, data, total) {
              var isStickySearch = (searchOptions.tagPrefix === options.stickyPrefix),
                itemString = '',
                frag = document.createElement('div'),
                makerID = $('meta[name=\'maker-id\']').attr('content'),
      Severity: Major
      Found in public/js/base/gallery.js - About 2 hrs to fix

        Function addCSP has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports.addCSP = function (options) {
          return hood.csp({
            headers: [
              'Content-Security-Policy-Report-Only'
            ],
        Severity: Major
        Found in lib/middleware.js - About 2 hrs to fix

          Function getSvgPlacement has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function getSvgPlacement(element, placement) {
                      var svgElement = element.closest('svg')[0],
                          domElement = element[0],
                          point = svgElement.createSVGPoint(),
                          boundingBox = domElement.getBBox(),
          Severity: Major
          Found in public/js/lib/jquery.powertip.js - About 2 hrs to fix

            Function powerTip has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                $.fn.powerTip = function(opts, arg) {
                    // don't do any work if there were no matched elements
                    if (!this.length) {
                        return this;
                    }
            Severity: Major
            Found in public/js/lib/jquery.powertip.js - About 2 hrs to fix

              Function permissionsModel has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var permissionsModel = function (options) {
                  var permissions = {
                    'webmaker-super-mentor': {
                      'issue': 3,
                      'applications': 3,
              Severity: Minor
              Found in lib/badges-permissions-model.js - About 1 hr to fix

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

                        link: function ($scope, $element, $attrs) {
                          var options = [];
                          var lang;
                          for (var i = 0; i < config.supported_languages.length; i++) {
                            lang = config.supported_languages[i];
                Severity: Minor
                Found in public/js/angular/directives.js - About 1 hr to fix

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

                    UI.pagination = function (page, total, limit, callback) {
                      var $pagination = $('.pagination'),
                        $ul = $pagination.find('ul'),
                        $li = $('<li></li>'),
                        $pageBtn,
                  Severity: Minor
                  Found in public/js/base/ui.js - About 1 hr to fix

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

                      UI.select = function (select, fn) {
                        $('.filter').removeClass('hide');
                    
                        var $el = $('.ui-select', $fragments).clone(true),
                          $toggleBtn = $el.find('.icon'),
                    Severity: Minor
                    Found in public/js/base/ui.js - About 1 hr to fix

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

                            function onboardingExperience() {
                              $('#home-start-form').on('submit', function () {
                                $rootScope.joinWebmaker($('.home-email-field').val(), '', $('#onboarding-checkbox').prop('checked'));
                              });
                              var input = $('.onboarding-input');
                      Severity: Minor
                      Found in public/js/angular/controllers.js - About 1 hr to fix

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

                                function getHtmlPlacement(element, placement) {
                                    var objectOffset = element.offset(),
                                        objectWidth = element.outerWidth(),
                                        objectHeight = element.outerHeight(),
                                        left,
                        Severity: Minor
                        Found in public/js/lib/jquery.powertip.js - About 1 hr to fix

                          Function SocialMedia has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            return function SocialMedia( options ) {
                              var urlPlaceHolder = options.url || "__URL__PLACE__HOLDER__";
                          
                              /**
                               * The various social media all have the same API.
                          Severity: Minor
                          Found in public/js/lib/socialmedia.js - About 1 hr to fix

                            Function process has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                makeClient.process = function (callback, id) {
                                  makeClient.then(function (err, data, totalHits) {
                                    if (err) {
                                      return callback(err);
                                    }
                            Severity: Minor
                            Found in lib/makeapi.js - About 1 hr to fix

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

                              module.exports = function (req, res) {
                                var make = require('../lib/makeapi').readOnly,
                                  querystring = require('querystring');
                              
                                var DEFAULT_TYPE = 'tags',
                              Severity: Minor
                              Found in routes/search.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 showTip has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      function showTip(element) {
                                          var tipContent;
                              
                                          // it is possible, especially with keyboard navigation, to move on to
                                          // another element with a tooltip during the queue to get to this point
                              Severity: Minor
                              Found in public/js/lib/jquery.powertip.js - About 1 hr to fix

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

                                module.exports = function (req, res) {
                                  var make = require('../lib/makeapi').authenticated,
                                    username = req.session.user ? req.session.user.username : '',
                                    page = req.query.page || 1,
                                    app = req.query.app,
                                Severity: Minor
                                Found in routes/me.js - About 1 hr to fix

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

                                  module.exports = function (options) {
                                    return function (req, res, next) {
                                      var DEFAULT_LAYOUT = 'index',
                                        DEFAULT_LIMIT = 12,
                                        layouts = {
                                  Severity: Minor
                                  Found in routes/gallery.js - About 1 hr to fix

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

                                    module.exports = function (options) {
                                      return function (req, res, next) {
                                        var DEFAULT_PREFIX = 'p',
                                          DEFAULT_LAYOUT = 'index',
                                          DEFAULT_STICKY_LIMIT = 24, // Larger to account for possible duplicates
                                    Severity: Minor
                                    Found in routes/gallery_old.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 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/base/gallery.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language