BadrIT/translation_center

View on GitHub

Showing 161 of 426 total issues

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

    def update_translation
      @translation = current_user.translation_for @translation_key, session[:lang_to]
      @key_before_status = @translation_key.status(session[:lang_to])
      respond_to do |format|
        # only admin can edit accepted translations
Severity: Minor
Found in app/controllers/translation_center/translation_keys_controller.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 isOver has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    isOver: function( y, x, top, left, height, width ) {
Severity: Minor
Found in app/assets/javascripts/translation_center/jquery-ui.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            switch (col) {
                                case 0: calender += ' ui-datepicker-group-first';
                                    cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
                                case numMonths[1]-1: calender += ' ui-datepicker-group-last';
                                    cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
    Severity: Major
    Found in app/assets/javascripts/translation_center/jquery-ui.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if (lookAhead("'"))
                                      output += "'";
                                  else
                                      literal = true;
      Severity: Major
      Found in app/assets/javascripts/translation_center/jquery-ui.js - About 45 mins to fix

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

          def self.yaml2db_key(locale, translation_key, translator, all_yamls)
            I18n.locale = locale
            translation = TranslationCenter::Translation.find_or_initialize_by(translation_key_id: translation_key.id, lang: locale.to_s, translator_id: translator.id)
            translation.translator_type = TranslationCenter::CONFIG['translator_type']
            
        Severity: Minor
        Found in lib/translation_center/translations_transfer.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

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

              def add_to_hash_rec(all_translations, levels, lang)
                current_level = levels.first
                # if we are at the bottom level just return the translation
                if(levels.count == 1)
                  translation = self.accepted_translation_in(lang)
        Severity: Minor
        Found in app/models/translation_center/translation_key.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

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

          def self.yaml2db_keys(keys, translator, locales, all_yamls)
            # initialize stats variables
            new_keys = 0
            missing_keys = locales.inject({}) do |memo, lang|
              memo[lang] = 0
        Severity: Minor
        Found in lib/translation_center/translations_transfer.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

        Consider simplifying this complex logical expression.
        Open

                    if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
                        dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
                        event.keyCode === $.ui.keyCode.ESCAPE ) {
        
                        dialog.close( event );
        Severity: Major
        Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                  if ( tab.hasClass( "ui-state-disabled" ) ||
                          // tab is already loading
                          tab.hasClass( "ui-tabs-loading" ) ||
                          // can't switch durning an animation
                          this.running ||
          Severity: Major
          Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if ( o.mode === "toggle" && mode === "show" ) {
                    el.from = o.to || zero;
                    el.to = o.from || original;
                } else {
                    el.from = o.from || ( mode === "show" ? zero : original );
            Severity: Major
            Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

              if ( $.uiBackCompat !== false ) {
              
                  // helper method for a lot of the back compat extensions
                  $.ui.tabs.prototype._ui = function( tab, panel ) {
                      return {
              Severity: Major
              Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                                if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
                                    curElem = hook === "backgroundColor" ? elem.parentNode : elem;
                                    while (
                                        (backgroundColor === "" || backgroundColor === "transparent") &&
                                        curElem && curElem.style
                Severity: Major
                Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if(
                                  inst.options.greedy
                                  && !inst.options.disabled
                                  && inst.options.scope == draggable.options.scope
                                  && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
                  Severity: Major
                  Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
                                    // #6694 - don't focus the input if it's already focused
                                    // this breaks the change event in IE
                                    inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
                                inst.input.focus();
                    Severity: Major
                    Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if ( ( this.options.values.length === 2 && this.options.range === true ) &&
                                          ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
                                      ) {
                                      newVal = otherVal;
                                  }
                      Severity: Major
                      Found in app/assets/javascripts/translation_center/jquery-ui.js - About 40 mins to fix

                        Function _dialogDatepicker has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            _dialogDatepicker: function(input, date, onSelect, settings, pos) {
                        Severity: Minor
                        Found in app/assets/javascripts/translation_center/jquery-ui.js - About 35 mins to fix

                          Function switchClass has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              switchClass: function( remove, add, speed, easing, callback) {
                          Severity: Minor
                          Found in app/assets/javascripts/translation_center/jquery-ui.js - About 35 mins to fix

                            Function toggleClass has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                toggleClass: function( classNames, force, speed, easing, callback ) {
                            Severity: Minor
                            Found in app/assets/javascripts/translation_center/jquery-ui.js - About 35 mins to fix

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

                                def self.yaml2db(locale=nil)
                              
                                  # prepare translator by creating the translator if he doesn't exist
                                  translator = TranslationCenter.prepare_translator
                              
                              
                              Severity: Minor
                              Found in lib/translation_center/translations_transfer.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

                              Avoid too many return statements within this function.
                              Open

                                      return true;
                              Severity: Major
                              Found in app/assets/javascripts/translation_center/jquery-ui.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language