PikachuEXE/i18n-js

View on GitHub

Showing 12 of 12 total issues

File i18n.js has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// I18n.js
// =======
//
// This small library provides the Rails I18n API on the Javascript.
// You don't actually have to use Rails (or even Ruby) to use I18n.js.
Severity: Minor
Found in app/assets/javascripts/i18n.js - About 6 hrs to fix

    Function indexOf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
            "use strict";
            if (this == null) {
                throw new TypeError();
            }
    Severity: Minor
    Found in app/assets/javascripts/i18n/shims.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

    Method filter has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.filter(translations, scopes)
          scopes = scopes.split(".") if scopes.is_a?(String)
          scopes = scopes.clone
          scope = scopes.shift
    
    
    Severity: Minor
    Found in lib/i18n/js.rb - About 2 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 strftime has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      I18n.strftime = function(date, format) {
        var options = this.lookup("date");
    
        if (!options) {
          options = DAYS_AND_MONTHS;
    Severity: Minor
    Found in app/assets/javascripts/i18n.js - About 2 hrs to fix

      Function forEach has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        Array.prototype.forEach = function forEach( callback, thisArg ) {
      
          var T, k;
      
          if ( this == null ) {
      Severity: Minor
      Found in app/assets/javascripts/i18n/shims.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 toNumber has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        I18n.toNumber = function(number, options) {
          options = this.prepareOptions(
              options
            , this.lookup("number.format")
            , NUMBER_FORMAT
      Severity: Minor
      Found in app/assets/javascripts/i18n.js - About 1 hr to fix

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

          I18n.toHumanSize = function(number, options) {
            var kb = 1024
              , size = number
              , iterations = 0
              , unit
        Severity: Minor
        Found in app/assets/javascripts/i18n.js - About 1 hr to fix

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

            I18n.lookup = function(scope, options) {
              options = this.prepareOptions(options);
          
              var locales = this.locales.get(options.locale)
                , requestedLocale = locales[0]
          Severity: Minor
          Found in app/assets/javascripts/i18n.js - About 1 hr to fix

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

                Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
                    "use strict";
                    if (this == null) {
                        throw new TypeError();
                    }
            Severity: Minor
            Found in app/assets/javascripts/i18n/shims.js - About 1 hr to fix

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

                I18n.parseDate = function(date) {
                  var matches, convertedDate;
              
                  // we have a date, so just return it.
                  if (typeof(date) == "object") {
              Severity: Minor
              Found in app/assets/javascripts/i18n.js - About 1 hr to fix

                Method configured_segments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.configured_segments
                      config[:translations].each_with_object({}) do |options, segments|
                        options.reverse_merge!(:only => "*")
                        if options[:file] =~ ::I18n::INTERPOLATION_PATTERN
                          segments.merge!(segments_per_locale(options[:file], options[:only]))
                Severity: Minor
                Found in lib/i18n/js.rb - About 35 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

                Method translation_segments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.translation_segments
                      segments = if config? && config[:translations]
                        configured_segments
                      else
                        {"#{export_dir}/translations.js" => translations}
                Severity: Minor
                Found in lib/i18n/js.rb - 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