expertiza/expertiza

View on GitHub

Showing 431 of 4,497 total issues

Method render_participant_info has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def render_participant_info(topic, assignment, participants)
    html = ''
    if participants.present?
      chooser_present = false
      participants.each do |participant|
Severity: Minor
Found in app/helpers/sign_up_sheet_helper.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

File impersonate_controller_spec.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe ImpersonateController do
  let(:instructor) { build(:instructor, id: 2) }
  let(:student1) { build(:student, id: 30, name: :Amanda) }
  let(:student2) { build(:student, id: 40, name: :Brian) }
  let(:admin) { build(:admin, id: 3, name: :Admin) }
Severity: Minor
Found in spec/controllers/impersonate_controller_spec.rb - About 2 hrs to fix

    File collusion_cycle_spec.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    describe CollusionCycle do
      #
      # assignment participant -----
      #    ^                       |
      #    |                       V
    Severity: Minor
    Found in spec/models/collusion_cycle_spec.rb - About 2 hrs to fix

      Function componentWillMount has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          componentWillMount: function() {
            var _this = this
            preloadImages(
              '/assets/tree_view/edit-icon-24.png',
              '/assets/tree_view/delete-icon-24.png',
      Severity: Major
      Found in app/assets/javascripts/tree_display.jsx - About 2 hrs to fix

        Method process_translation has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_translation(contents, key, val)
            replacements = []
            skips = []
            resume_index = 0
            while resume_index < contents.length
        Severity: Minor
        Found in app/models/view_translation_substitutor.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

        Method list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def list
            @participant = AssignmentParticipant.find(params[:id].to_i)
            @assignment = @participant.assignment
            @slots_filled = SignUpTopic.find_slots_filled(@assignment.id)
            @slots_waitlisted = SignUpTopic.find_slots_waitlisted(@assignment.id)
        Severity: Minor
        Found in app/controllers/sign_up_sheet_controller.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

        Method classify_controllers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def classify_controllers
            from_classes = SiteController.classes
        
            from_db = SiteController.order(:name)
            known = {}
        Severity: Minor
        Found in app/controllers/site_controllers_controller.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

        File import_file_controller.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class ImportFileController < ApplicationController
          include AuthorizationHelper
        
          def action_allowed?
            current_user_has_ta_privileges?
        Severity: Minor
        Found in app/controllers/import_file_controller.rb - About 2 hrs to fix

          Class Role has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Role < ApplicationRecord
            belongs_to :parent, class_name: 'Role', inverse_of: false
            has_many :users, inverse_of: false, dependent: :nullify
          
            serialize :cache
          Severity: Minor
          Found in app/models/role.rb - About 2 hrs to fix

            Method display_volume_metric_chart has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def display_volume_metric_chart(reviewer)
                labels, reviewer_data, all_reviewers_data = initialize_chart_elements(reviewer)
                data = {
                  labels: labels,
                  datasets: [
            Severity: Major
            Found in app/helpers/review_mapping_helper.rb - About 2 hrs to fix

              Method peer_review_strategy has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def peer_review_strategy(assignment_id, review_strategy, participants_hash)
                  teams = review_strategy.teams
                  participants = review_strategy.participants
                  num_participants = participants.size
              
              
              Severity: Major
              Found in app/controllers/review_mapping_controller.rb - About 2 hrs to fix

                Method assessments_for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.assessments_for(team)
                    responses = []
                    # stime = Time.now
                    if team
                      @array_sort = []
                Severity: Minor
                Found in app/models/response_map.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

                Method view_completed_question has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def view_completed_question(count, answer, questionnaire_max, tag_prompt_deployments = nil, current_user = nil)
                    html = '<b>' + count.to_s + '. ' + txt + ' [Max points: ' + questionnaire_max.to_s + ']</b>'
                    score = answer && !answer.answer.nil? ? answer.answer.to_s : '-'
                    score_percent = score != '-' ? answer.answer * 1.0 / questionnaire_max : 0
                    score_color = if score_percent > 0.8
                Severity: Minor
                Found in app/models/criterion.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

                Method automatic_review_mapping has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def automatic_review_mapping
                    assignment_id = params[:id].to_i
                    assignment = Assignment.find(params[:id])
                    participants = AssignmentParticipant.where(parent_id: params[:id].to_i).to_a.select(&:can_review).shuffle!
                    teams = AssignmentTeam.where(parent_id: params[:id].to_i).to_a.shuffle!
                Severity: Minor
                Found in app/controllers/review_mapping_controller.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

                Method hash_rows_with_headers has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def hash_rows_with_headers(header, body)
                    new_body = []
                    if (params[:model] == 'User') || (params[:model] == 'AssignmentParticipant') || (params[:model] == 'CourseParticipant') || (params[:model] == 'SignUpTopic')
                      header.map! { |str| str.strip.downcase.gsub(/\s+/, "").to_sym }
                      body.each do |row|
                Severity: Major
                Found in app/controllers/import_file_controller.rb - About 2 hrs to fix

                  File tree_display_controller.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class TreeDisplayController < ApplicationController
                    helper :application
                    include SecurityHelper
                    include AuthorizationHelper
                  
                  
                  Severity: Minor
                  Found in app/controllers/tree_display_controller.rb - About 2 hrs to fix

                    File review_response_map_spec.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    describe ReviewResponseMap do
                      let(:team) { build(:assignment_team, id: 1, name: 'team no name', assignment: assignment, users: [student], parent_id: 1) }
                      let(:team2) { build(:assignment_team, id: 3, name: 'no team') }
                      let(:team1) { build(:assignment_team, id: 2, name: 'team has name', assignment: assignment, users: [student]) }
                      let(:team3) { build(:assignment_team, id: 4, name: 'team has name1', assignment: assignment, users: [student1]) }
                    Severity: Minor
                    Found in spec/models/review_response_map_spec.rb - About 2 hrs to fix

                      Method create has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def create
                          user = User.find_by(name: params[:user][:name].strip)
                          unless user
                            urlCreate = url_for controller: 'users', action: 'new'
                            flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please <a href=\"#{urlCreate}\">create</a> this user before continuing."
                      Severity: Major
                      Found in app/controllers/teams_users_controller.rb - About 2 hrs to fix

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

                          def assignment_tagging_progress
                            teams = Team.where(parent_id: assignment_id)
                            questions = Question.where(questionnaire_id: questionnaire.id, type: question_type)
                            questions_ids = questions.map(&:id)
                            user_answer_tagging = []
                        Severity: Minor
                        Found in app/models/tag_prompt_deployment.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

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

                          def add_table_rows(questionnaire_max, questions, answers, code, tag_prompt_deployments = nil, current_user = nil)
                            count = 0
                            # loop through questions so the the questions are displayed in order based on seq (sequence number)
                            questions.each do |question|
                              count += 1 if !question.is_a?(QuestionnaireHeader) && (question.break_before == true)
                        Severity: Minor
                        Found in app/models/response.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

                        Severity
                        Category
                        Status
                        Source
                        Language