thiagofm/memcached-manager

View on GitHub
lib/public/javascripts/humanize_duration.js

Summary

Maintainability
F
1 wk
Test Coverage

File humanize_duration.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// HumanizeDuration.js - http://git.io/j0HgmQ

(function() {

  var UNITS = {
Severity: Minor
Found in lib/public/javascripts/humanize_duration.js - About 2 hrs to fix

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

      function doHumanization(ms, options) {
    
        // Make sure we have a positive number.
        // Has the nice sideffect of turning Number objects into primitives.
        ms = Math.abs(ms);
    Severity: Minor
    Found in lib/public/javascripts/humanize_duration.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          } else if (c === 0 || (c >= 5 && c <= 20) || (c % 10 >= 5 && c % 10 <= 9) || (c % 10 === 0) ) {
            return 0;
          } else if (c === 1 || c % 10 === 1) {
            return 1;
          } else if (c > 1) {
      Severity: Major
      Found in lib/public/javascripts/humanize_duration.js - About 40 mins to fix

        Avoid too many return statements within this function.
        Open

              return 0;
        Severity: Major
        Found in lib/public/javascripts/humanize_duration.js - About 30 mins to fix

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

              de: {
                year: function(c) { return "jahr" + ((c !== 1) ? "e" : ""); },
                month: function(c) { return "monat" + ((c !== 1) ? "e" : ""); },
                week: function(c) { return "woche" + ((c !== 1) ? "n" : ""); },
                day: function(c) { return "tag" + ((c !== 1) ? "e" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 3 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 17..26
          lib/public/javascripts/humanize_duration.js on lines 47..56
          lib/public/javascripts/humanize_duration.js on lines 67..76

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

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

              en: {
                year: function(c) { return "year" + ((c !== 1) ? "s" : ""); },
                month: function(c) { return "month" + ((c !== 1) ? "s" : ""); },
                week: function(c) { return "week" + ((c !== 1) ? "s" : ""); },
                day: function(c) { return "day" + ((c !== 1) ? "s" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 3 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 17..26
          lib/public/javascripts/humanize_duration.js on lines 37..46
          lib/public/javascripts/humanize_duration.js on lines 67..76

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

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

              es: {
                year: function(c) { return "año" + ((c !== 1) ? "s" : ""); },
                month: function(c) { return "mes" + ((c !== 1) ? "es" : ""); },
                week: function(c) { return "semana" + ((c !== 1) ? "s" : ""); },
                day: function(c) { return "día" + ((c !== 1) ? "s" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 3 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 17..26
          lib/public/javascripts/humanize_duration.js on lines 37..46
          lib/public/javascripts/humanize_duration.js on lines 47..56

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

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

              ca: {
                year: function(c) { return "any" + ((c !== 1) ? "s" : ""); },
                month: function(c) { return "mes" + ((c !== 1) ? "os" : ""); },
                week: function(c) { return "setman" + ((c !== 1) ? "es" :"a"); },
                day: function(c) { return "di" + ((c !== 1) ? "es" :"a"); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 3 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 37..46
          lib/public/javascripts/humanize_duration.js on lines 47..56
          lib/public/javascripts/humanize_duration.js on lines 67..76

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

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

              nob: {
                year: "år",
                month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
                week: function(c) { return "uke" + ((c !== 1) ? "r" : ""); },
                day: function(c) { return "dag" + ((c !== 1) ? "er" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 2 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 27..36
          lib/public/javascripts/humanize_duration.js on lines 147..156

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

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

              da: {
                year: "år",
                month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
                week: function(c) { return "uge" + ((c !== 1) ? "r" : ""); },
                day: function(c) { return "dag" + ((c !== 1) ? "e" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 2 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 107..116
          lib/public/javascripts/humanize_duration.js on lines 147..156

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

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

              sv: {
                year: "år",
                month: function(c) { return "månad" + ((c !== 1) ? "er" : ""); },
                week: function(c) { return "veck" + ((c !== 1) ? "or" : "a"); },
                day: function(c) { return "dag" + ((c !== 1) ? "ar" : ""); },
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 2 other locations - About 1 day to fix
          lib/public/javascripts/humanize_duration.js on lines 27..36
          lib/public/javascripts/humanize_duration.js on lines 107..116

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

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

              ja: {
                year: "年",
                month: "月",
                week: "週",
                day: "日",
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 5 other locations - About 35 mins to fix
          lib/public/javascripts/humanize_duration.js on lines 97..106
          lib/public/javascripts/humanize_duration.js on lines 157..166
          lib/public/javascripts/jquery-terminal.js on lines 1935..1944
          lib/public/javascripts/jquery-terminal.js on lines 1945..1954
          lib/public/javascripts/jquery-terminal.js on lines 1955..1964

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

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

              tr: {
                year: "yıl",
                month: "ay",
                week: "hafta",
                day: "gün",
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 5 other locations - About 35 mins to fix
          lib/public/javascripts/humanize_duration.js on lines 87..96
          lib/public/javascripts/humanize_duration.js on lines 97..106
          lib/public/javascripts/jquery-terminal.js on lines 1935..1944
          lib/public/javascripts/jquery-terminal.js on lines 1945..1954
          lib/public/javascripts/jquery-terminal.js on lines 1955..1964

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

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

              ko: {
                year: "년",
                month: "개월",
                week: "주일",
                day: "일",
          Severity: Major
          Found in lib/public/javascripts/humanize_duration.js and 5 other locations - About 35 mins to fix
          lib/public/javascripts/humanize_duration.js on lines 87..96
          lib/public/javascripts/humanize_duration.js on lines 157..166
          lib/public/javascripts/jquery-terminal.js on lines 1935..1944
          lib/public/javascripts/jquery-terminal.js on lines 1945..1954
          lib/public/javascripts/jquery-terminal.js on lines 1955..1964

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

          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

              "zh-CN": {
                year: "年",
                month: "个月",
                week: "周",
                day: "天",
          Severity: Minor
          Found in lib/public/javascripts/humanize_duration.js and 1 other location - About 35 mins to fix
          lib/public/javascripts/humanize_duration.js on lines 177..186

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

          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

              "zh-TW": {
                year: "年",
                month: "個月",
                week: "周",
                day: "天",
          Severity: Minor
          Found in lib/public/javascripts/humanize_duration.js and 1 other location - About 35 mins to fix
          lib/public/javascripts/humanize_duration.js on lines 167..176

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

          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

          There are no issues that match your filters.

          Category
          Status