ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

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

    it 'when params[:id] is not nil but role_id is nil' do
      allow(controller).to receive(:current_user).and_return(student6)
      allow(User).to receive(:find).with('6').and_return(student6)
      @params = {id: 6}
      session = {user: student6}
Severity: Minor
Found in spec/controllers/users_controller_spec.rb and 1 other location - About 40 mins to fix
spec/controllers/users_controller_spec.rb on lines 95..101

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

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

Method get_children has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def get_children(_sortvar = nil, _sortorder = nil, _user_id = nil, _parent_id = nil, _search = nil)
Severity: Minor
Found in app/models/team_node.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def initialize(user, percentage, no_tagged, no_not_tagged, no_tagable)
    Severity: Minor
    Found in app/models/vm_user_answer_tagging.rb - About 35 mins to fix

      Method cancel_all_wailists has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def self.cancel_all_wailists(assignment_id, sign_up, team_id, topic_id, user_id)
      Severity: Minor
      Found in app/models/sign_up_sheet.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def initialize(question_text, question_id, weight, question_max_score, seq)
        Severity: Minor
        Found in app/models/vm_question_response_row.rb - About 35 mins to fix

          Method sign_up_wailisted has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.sign_up_wailisted(assignment_id, sign_up, team_id, topic_id, user_id)
          Severity: Minor
          Found in app/models/sign_up_sheet.rb - About 35 mins to fix

            Method handle_duplicate has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def self.handle_duplicate(team, name, id, handle_dups, teamtype)
            Severity: Minor
            Found in app/models/team.rb - About 35 mins to fix

              Method automatic_review_mapping_strategy has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def automatic_review_mapping_strategy(assignment_id,
                                                      participants, teams, student_review_num = 0,
                                                      submission_review_num = 0)
              Severity: Minor
              Found in app/controllers/review_mapping_controller.rb - About 35 mins to fix

                Method complete has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def complete(count, answer = nil, questionnaire_min, questionnaire_max, dropdown_or_scale)
                Severity: Minor
                Found in app/models/criterion.rb - About 35 mins to fix

                  Method display_as_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def display_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil)
                  Severity: Minor
                  Found in app/models/response.rb - About 35 mins to fix

                    Method view_completed_question has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def view_completed_question(count, answer, questionnaire_max, tag_prompt_deployments = nil, current_user = nil)
                    Severity: Minor
                    Found in app/models/criterion.rb - About 35 mins to fix

                      Method topic_due has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def topic_due(type, time, topic_id, round, review_allowed_id = 3)
                      Severity: Minor
                      Found in spec/features/staggered_deadline_spec.rb - About 35 mins to fix

                        Function GenCell has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
                        {
                            var PValue;
                            var PCellStr;
                            var vColor;
                        Severity: Minor
                        Found in app/assets/javascripts/datetimepicker.js - 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

                        Function expandtab has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            expandtab:function(tabref){
                                var relattrvalue=tabref.getAttribute("rel")
                                //Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
                                var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
                                if (relattrvalue=="#default")
                        Severity: Minor
                        Found in app/assets/javascripts/ajaxtabs.js - 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 calc_review_score has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def calc_review_score
                          if !@corresponding_response.empty?
                            @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)
                            if @this_review_score_raw
                              @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0
                        Severity: Minor
                        Found in app/models/on_the_fly_calc.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 import has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.import(row_hash, session, _id = nil)
                            raise 'Not enough items: expect 2 or more columns: Topic Identifier, User Name 1, User Name 2, ...' if row_hash.length < 2
                        
                            imported_topic = SignUpTopic.where(topic_identifier: row_hash[:topic_identifier], assignment_id: session[:assignment_id]).first
                        
                        
                        Severity: Minor
                        Found in app/models/sign_up_sheet.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 randomize_all_by_parent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.randomize_all_by_parent(parent, team_type, min_team_size)
                            participants = Participant.where(parent_id: parent.id, type: parent.class.to_s + "Participant")
                            participants = participants.sort { rand(-1..1) }
                            users = participants.map {|p| User.find(p.user_id) }.to_a
                            # find teams still need team members and users who are not in any team
                        Severity: Minor
                        Found in app/models/team.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

                        Function cycleit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
                                if (dir=="next"){
                                    var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
                                }
                                else if (dir=="prev"){
                        Severity: Minor
                        Found in app/assets/javascripts/ajaxtabs.js - 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

                        Function getSelectedName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function getSelectedName(){
                            var tbl = document.getElementById("file_table");
                            var numChecks = 0;
                            for(i=0; i<document.forms[2].elements.length; i++){
                                if(document.forms[2].elements[i].type=="radio" &&
                        Severity: Minor
                        Found in app/assets/javascripts/submissions.js - 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

                        Function checkTopicForDuplicatesAndRequiredColumns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function checkTopicForDuplicatesAndRequiredColumns(optional_count) {
                        
                            var sel1 = document.getElementById("select1");
                            var sel2 = document.getElementById("select2");
                            var sel3 = document.getElementById("select3");
                        Severity: Minor
                        Found in app/assets/javascripts/shared.js - 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

                        Severity
                        Category
                        Status
                        Source
                        Language