mozilla/webmaker.org

View on GitHub

Showing 111 of 111 total issues

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

  for (var i = 0; i < config.supported_languages.length; i++) {
    lang = config.supported_languages[i];
    options.push({
      id: lang,
      title: config.langmap[lang] ? config.langmap[lang].nativeName : lang,
Severity: Major
Found in public/js/pages/localweb.js and 1 other location - About 4 hrs to fix
public/js/angular/directives.js on lines 273..280

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

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

          for (var i = 0; i < config.supported_languages.length; i++) {
            lang = config.supported_languages[i];
            options.push({
              id: lang,
              title: config.langmap[lang] ? config.langmap[lang].nativeName : lang,
Severity: Major
Found in public/js/angular/directives.js and 1 other location - About 4 hrs to fix
public/js/pages/localweb.js on lines 89..96

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 exports has 106 lines of code (exceeds 25 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: Major
Found in routes/gallery_old.js - About 4 hrs to fix

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

    module.exports = function (app) {
      var redirectMap = [{
        // Switch to SSL after Bug 883370 lands.
        route: 'http://blog.webmaker.org',
        paths: [
    Severity: Major
    Found in routes/redirect.js - About 4 hrs to fix

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

      module.exports = function (options) {
        var moment = require('moment');
        var MakeClient = require('makeapi-client');
      
        function generateGravatar(hash) {
      Severity: Major
      Found in lib/makeapi.js - About 3 hrs to fix

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

        module.exports = function (req, res) {
          var make = require('../lib/makeapi').readOnly,
            querystring = require('querystring');
        
          var DEFAULT_TYPE = 'tags',
        Severity: Major
        Found in routes/search.js - About 3 hrs to fix

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

          module.exports = function (env) {
            // Error messages
            var errorHandlers = {
              unauthorized: function () {
                var err = new Error('You must be logged in to access this area.');
          Severity: Minor
          Found in routes/badges.js - About 3 hrs 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 createMakeClient has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function createMakeClient(url, hawk) {
              var options = {
                apiURL: url
              };
              if (hawk) {
          Severity: Major
          Found in lib/makeapi.js - About 3 hrs to fix

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

                create: function (req, res, next) {
                  var context = {
                    system: env.get('BADGES_SYSTEM'),
                    badge: req.body
                  };
            Severity: Major
            Found in routes/badges.js and 1 other location - About 3 hrs to fix
            routes/badges.js on lines 383..394

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

            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

                update: function (req, res, next) {
                  var context = {
                    system: env.get('BADGES_SYSTEM'),
                    badge: req.body
                  };
            Severity: Major
            Found in routes/badges.js and 1 other location - About 3 hrs to fix
            routes/badges.js on lines 371..382

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

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

                details: function (req, res, next) {
                  function getBadge(callback) {
                    badgeClient.getBadge({
                      system: env.get('BADGES_SYSTEM'),
                      badge: req.params.badge
            Severity: Major
            Found in routes/badges.js - About 3 hrs to fix

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

              module.exports = function (req, res) {
                var MAX_REMIXES = 5;
                var make = require('../lib/makeapi').authenticated;
              
                function renderError(message) {
              Severity: Major
              Found in routes/details.js - About 2 hrs to fix

                Function DisplayController has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function DisplayController(element, options, tipController) {
                        var hoverTimer = null;
                
                        /**
                         * Begins the process of showing a tooltip.
                Severity: Major
                Found in public/js/lib/jquery.powertip.js - About 2 hrs to fix

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

                                    if (matches) {
                                      if (matches[1] && matches[2]) {
                                        matchesLang = matches[1].toLowerCase() + matches[2].toUpperCase();
                                      } else {
                                        matchesLang = matches[1].toLowerCase();
                  Severity: Major
                  Found in public/js/angular/directives.js and 2 other locations - About 2 hrs to fix
                  public/js/angular/controllers.js on lines 699..705
                  public/js/pages/localweb.js on lines 112..118

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

                  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

                            if (values.length > 2) {
                              for (var index = 2; index < values.length; index++) {
                                var target = '{' + (index - 2) + '}';
                                tag = tag.replace(target, values[index]);
                              }
                  Severity: Major
                  Found in public/js/angular/i18n.js and 1 other location - About 2 hrs to fix
                  public/js/angular/i18n.js on lines 99..104

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

                  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 3 locations. Consider refactoring.
                  Open

                            if (matches) {
                              if (matches[1] && matches[2]) {
                                matchesLang = matches[1].toLowerCase() + matches[2].toUpperCase();
                              } else {
                                matchesLang = matches[1].toLowerCase();
                  Severity: Major
                  Found in public/js/angular/controllers.js and 2 other locations - About 2 hrs to fix
                  public/js/angular/directives.js on lines 297..303
                  public/js/pages/localweb.js on lines 112..118

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

                  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

                              if (values.length > 1) {
                                for (var index = 1; index < values.length; index++) {
                                  var target = '{' + (index - 1) + '}';
                                  tag = tag.replace(target, values[index]);
                                }
                  Severity: Major
                  Found in public/js/angular/i18n.js and 1 other location - About 2 hrs to fix
                  public/js/angular/i18n.js on lines 163..168

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

                  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 3 locations. Consider refactoring.
                  Open

                          if (matches) {
                            if (matches[1] && matches[2]) {
                              matchesLang = matches[1].toLowerCase() + matches[2].toUpperCase();
                            } else {
                              matchesLang = matches[1].toLowerCase();
                  Severity: Major
                  Found in public/js/pages/localweb.js and 2 other locations - About 2 hrs to fix
                  public/js/angular/controllers.js on lines 699..705
                  public/js/angular/directives.js on lines 297..303

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

                  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

                  File directives.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  angular
                    .module('webmakerApp')
                    .directive('wmAffix', ['$window', '$timeout',
                      function ($window, $timeout) {
                        return {
                  Severity: Minor
                  Found in public/js/angular/directives.js - About 2 hrs to fix

                    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
                      Severity
                      Category
                      Status
                      Source
                      Language