mose/rails-i18nterface

View on GitHub

Showing 33 of 52 total issues

File ender.js has 2318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
  * =============================================================
  * Ender: open module JavaScript framework (https://ender.no.de)
  * Build: ender build jeesh reqwest --output app/assets/javascripts/rails_i18nterface/ender
  * =============================================================
Severity: Major
Found in app/assets/javascripts/rails_i18nterface/ender.js - About 6 days to fix

    Function Event has 119 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          , Event = (function () {
                  // a whitelist of properties (for different event types) tells us what to check for and copy
              var commonProps  = str2arr('altKey attrChange attrName bubbles cancelable ctrlKey currentTarget ' +
                    'detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey '  +
                    'srcElement target timeStamp type view which propertyName')
    Severity: Major
    Found in app/assets/javascripts/rails_i18nterface/ender.js - About 4 hrs to fix

      Function init has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function init(o, fn) {
        
            this.url = typeof o == 'string' ? o : o.url
            this.timeout = null
        
      Severity: Major
      Found in app/assets/javascripts/rails_i18nterface/ender.js - About 3 hrs to fix

        Function RegEntry has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              , RegEntry = (function () {
                  // each handler is wrapped so we can handle delegation and custom events
                  var wrappedHandler = function (element, fn, condition, args) {
                      var call = function (event, eargs) {
                            return fn.apply(element, args ? slice.call(eargs, event ? 0 : 1).concat(args) : eargs)
        Severity: Major
        Found in app/assets/javascripts/rails_i18nterface/ender.js - About 2 hrs to fix

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

                , registry = (function () {
                    // our map stores arrays by event type, just because it's better than storing
                    // everything in a single array.
                    // uses '$' as a prefix for the keys for safety and 'r' as a special prefix for
                    // rootListeners so we can look them up fast
          Severity: Major
          Found in app/assets/javascripts/rails_i18nterface/ender.js - About 2 hrs to fix

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

                function handleJsonp(o, fn, err, url) {
                  var reqId = uniqid++
                    , cbkey = o.jsonpCallback || 'callback' // the 'callback' key
                    , cbval = o.jsonpCallbackName || reqwest.getcallbackPrefix(reqId)
                    // , cbval = o.jsonpCallbackName || ('reqwest_' + reqId) // the 'callback' value
            Severity: Minor
            Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

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

                    , on = function(element, events, selector, fn) {
                        var originalFn, type, types, i, args, entry, first
                
                        //TODO: the undefined check means you can't pass an 'args' argument, fix this perhaps?
                        if (selector === undefined && typeof events == 'object') {
              Severity: Minor
              Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                Function interpret has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value, wholePseudo, pseudo, wholePseudoVal, pseudoVal) {
                Severity: Major
                Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                  Function css has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        , css: function (o, opt_v) {
                            var p, iter = o
                            // is this a request for just getting a style?
                            if (opt_v === undefined && typeof o == 'string') {
                              // repurpose 'v'
                  Severity: Minor
                  Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                    Function offset has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          , offset: function (opt_x, opt_y) {
                              if (opt_x && typeof opt_x == 'object' && (typeof opt_x.top == 'number' || typeof opt_x.left == 'number')) {
                                return this.each(function (el) {
                                  xy(el, opt_x.left, opt_x.top)
                                })
                    Severity: Minor
                    Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                      Function serial has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function serial(el, cb) {
                            var n = el.name
                              , t = el.tagName.toLowerCase()
                              , optCb = function (o) {
                                  // IE gives value="" even where there is no value attribute
                      Severity: Minor
                      Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                        Function dim has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              , dim: function () {
                                  if (!this.length) return { height: 0, width: 0 }
                                  var el = this[0]
                                    , de = el.nodeType == 9 && el.documentElement // document
                                    , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
                        Severity: Minor
                        Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                          Function success has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                function success(resp) {
                                  var r = resp.responseText
                                  if (r) {
                                    switch (type) {
                                    case 'json':
                          Severity: Minor
                          Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                  if (o) {
                                    o.type && (o.method = o.type) && delete o.type
                                    o.dataType && (o.type = o.dataType)
                                    o.jsonpCallback && (o.jsonpCallbackName = o.jsonpCallback) && delete o.jsonpCallback
                                    o.jsonp && (o.jsonpCallback = o.jsonp)
                            Severity: Major
                            Found in app/assets/javascripts/rails_i18nterface/ender.js - About 1 hr to fix

                              Method remove_blanks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def remove_blanks(hash)
                                    hash.each do |k, v|
                                      hash.delete k if !v || v == '' || v.is_a?(Proc)
                                      if v.is_a? Hash
                                        remove_blanks v
                              Severity: Minor
                              Found in lib/rails-i18nterface/utils.rb - About 55 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 populate_keys has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def populate_keys(root_dir, file)
                                    files = {}
                                    IO.read(file).scan(pattern2).each do |key, key2, count|
                                      key = key || key2
                                      path = relative_path(root_dir, file)
                              Severity: Minor
                              Found in lib/rails-i18nterface/sourcefiles.rb - About 55 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 deep_sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def deep_sort(object)
                                    if object.is_a?(Hash)
                                      res = {}
                                      object.each { |k, v| res[k] = deep_sort(v) }
                                      Hash[res.sort { |a, b| a[0].to_s <=> b[0].to_s }]
                              Severity: Minor
                              Found in lib/rails-i18nterface/utils.rb - About 55 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

                              Function RegEntry has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                        , RegEntry = function (element, type, handler, original, namespaces, args, root) {
                              Severity: Major
                              Found in app/assets/javascripts/rails_i18nterface/ender.js - About 50 mins to fix

                                Method sort_keys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def sort_keys(order = 'key')
                                      if order == 'key'
                                        @all_keys.sort!
                                      else # text
                                        @all_keys.sort! do |key1, key2|
                                Severity: Minor
                                Found in lib/rails-i18nterface/keys.rb - About 45 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

                                Function forAll has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                            , forAll = function (element, type, original, handler, root, fn) {
                                Severity: Minor
                                Found in app/assets/javascripts/rails_i18nterface/ender.js - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language