mozilla/webmaker.org

View on GitHub

Showing 111 of 111 total issues

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

          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

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

                                      case 'n':
                                          coords.set('left', position.left - (tipWidth / 2));
                                          coords.set('bottom', session.windowHeight - position.top + offset);
                                          break;
                          Severity: Major
                          Found in public/js/lib/jquery.powertip.js and 1 other location - About 1 hr to fix
                          public/js/lib/jquery.powertip.js on lines 452..455

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

                          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

                                      case 'w':
                                          coords.set('top', position.top - (tipHeight / 2));
                                          coords.set('right', session.windowWidth - position.left + offset);
                                          break;
                          Severity: Major
                          Found in public/js/lib/jquery.powertip.js and 1 other location - About 1 hr to fix
                          public/js/lib/jquery.powertip.js on lines 440..443

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

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

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

                                    var layoutName = options.layout || (req.query.layout || DEFAULT_LAYOUT).toString(),
                                      layout = layouts[layoutName] || layouts[DEFAULT_LAYOUT];
                                Severity: Minor
                                Found in routes/gallery_old.js and 1 other location - About 55 mins to fix
                                routes/gallery.js on lines 18..19

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

                                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

                                    var layoutName = options.layout || (req.query.layout || DEFAULT_LAYOUT).toString(),
                                      layout = layouts[layoutName] || layouts[DEFAULT_LAYOUT];
                                Severity: Minor
                                Found in routes/gallery.js and 1 other location - About 55 mins to fix
                                routes/gallery_old.js on lines 40..41

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

                                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