talho/openphin

View on GitHub

Showing 3,486 of 3,486 total issues

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

  def to_s
    begin user_name = User.find(user_id).to_s rescue user_name = '-?-' end
    begin role_name = Role.find(role_id).to_s rescue role_name = '-?-' end
    begin jur_name = Jurisdiction.find(jurisdiction_id).to_s rescue jur_name = '-?-' end
    user_name + ' for ' + role_name + ' in ' + jur_name
Severity: Minor
Found in app/models/role_request.rb and 1 other location - About 45 mins to fix
app/models/role_membership.rb on lines 47..51

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

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

Avoid deeply nested control flow statements.
Open

                    if(folderSelections[0] && folderSelections[0].get('type').match(/share|organization/)){  // we want to figure out what sharing permissions we have, eventually, but for now, roll with it
                        show.push('copy_action_container', 'file_detail_container');
                        if(folderSelections[0].get('is_owner')){
                            show.push('move_action_container');
                        }
Severity: Major
Found in app/assets/javascripts/documents/Documents.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                for ( var handle in events[type] )
                                    // Handle the removal of namespaced events
                                    if ( namespace.test(events[type][handle].type) )
                                        delete events[type][handle];
    Severity: Major
    Found in app/assets/javascripts/jquery.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
                              if ( item ) {
                                  found = filter( item, match, i, curLoop );
                                  var pass = not ^ !!found;
      
      
      Severity: Major
      Found in app/assets/javascripts/jquery.js - About 45 mins to fix

        Function run_search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            run_search: function(val){
                if (!Ext.isEmpty(val) && val.length >= 2){
                    var own = this.getComponent('search_form').getComponent('my_files').checked;
                    var shared = this.getComponent('search_form').getComponent('shared_files').checked;
                    if(own || shared){ // We only want to do this if the file is either owned or shared.
        Severity: Minor
        Found in app/assets/javascripts/documents/DocumentSearch.js - 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

        Avoid deeply nested control flow statements.
        Open

                            if ( !inplace ) {
                                curLoop = result;
                            }
        Severity: Major
        Found in app/assets/javascripts/jquery.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if(sel.get('is_owner')){
                                  show.push('folder_action_container', 'move_action_container');
                                  this._add_folder_button.show();
                              }
          Severity: Major
          Found in app/assets/javascripts/documents/Documents.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if ( results[i] === results[i-1] ) {
                                    results.splice(i--, 1);
                                }
            Severity: Major
            Found in app/assets/javascripts/jquery.js - About 45 mins to fix

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

                      CLASS: function(match, curLoop, inplace, result, not, isXML){
              Severity: Minor
              Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if ( typeof cur !== "string" ) {
                                        if ( elem === cur ) {
                                            match = true;
                                            break;
                                        }
                Severity: Major
                Found in app/assets/javascripts/jquery.js - About 45 mins to fix

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

                            renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                  Severity: Minor
                  Found in app/assets/javascripts/invitations/Invitations.js - About 45 mins to fix

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

                    function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
                    Severity: Minor
                    Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if ( option.selected ) {
                                                  // Get the specifc value for the option
                                                  value = jQuery(option).val();
                      
                                                  // We don't need an array for one selects
                      Severity: Major
                      Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if ( !match ) {
                                                anyFound = found = true;
                                            } else if ( match === true ) {
                                                continue;
                                            }
                        Severity: Major
                        Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if ( display === "none" )
                                                      display = "block";
                          Severity: Major
                          Found in app/assets/javascripts/jquery.js - About 45 mins to fix

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

                                    ATTR: function(match, curLoop, inplace, result, not, isXML){
                            Severity: Minor
                            Found in app/assets/javascripts/jquery.js - About 45 mins to fix

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

                              function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
                              Severity: Minor
                              Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if ( !anyFound ) {
                                                        return [];
                                                    }
                                Severity: Major
                                Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
                                                                  if (elem.removeEventListener)
                                                                      elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
                                                                  else if (elem.detachEvent)
                                                                      elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
                                  Severity: Major
                                  Found in app/assets/javascripts/jquery.js - About 45 mins to fix

                                    Function applyModelSelections has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      applyModelSelections : function(){
                                        var selected_models = this.modelList.getSelectedRecords();
                                        if ( selected_models.length > 0 ){
                                          var models = [];
                                          for (var i = 0; i < selected_models.length; i++){
                                    Severity: Minor
                                    Found in app/assets/javascripts/admin/AuditLog.js - 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language