ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Function clearbrowseredge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function clearbrowseredge(obj, whichedge){
if (whichedge=="rightedge"){
edgeoffsetx=0
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
Severity: Minor
Found in app/assets/javascripts/balloontip.js - About 1 hr 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 two_node_cycles has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def two_node_cycles(assignment_participant)
    collusion_cycles = []
    assignment_participant.reviewers.each do |ap|
      next unless ap.reviewers.include?(assignment_participant)
      if assignment_participant.reviews_by_reviewer(ap).nil?
Severity: Minor
Found in app/models/collusion_cycle.rb - About 1 hr 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 adjust_advice_size has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.adjust_advice_size(questionnaire, question)
    # now we only support question advices for scored questions
    if question.is_a?(ScoredQuestion)

      max = questionnaire.max_question_score
Severity: Minor
Found in app/helpers/questionnaire_helper.rb - About 1 hr 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 run_intelligent_assignment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def run_intelligent_assignment
    priority_info = []
    assignment = Assignment.find_by(id: params[:id])
    topics = assignment.sign_up_topics
    teams = assignment.teams
Severity: Minor
Found in app/controllers/lottery_controller.rb - About 1 hr 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 display_directory_tree has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def display_directory_tree(participant, files, display_to_reviewer_flag)
    index = 0
    participant = @participant if @participant # TODO: Verify why this is needed
    assignment = participant.assignment # participant is @map.contributor
    topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) # participant is @map.reviewer
Severity: Minor
Found in app/helpers/submitted_content_helper.rb - About 1 hr 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 others_work has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def others_work
    @participant = AssignmentParticipant.find(params[:id])
    return unless current_user_id?(@participant.user_id)

    @assignment = @participant.assignment
Severity: Minor
Found in app/controllers/student_task_controller.rb - About 1 hr 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 redirect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def redirect
    flash[:error] = params[:error_msg] unless params[:error_msg] and params[:error_msg].empty?
    flash[:note] = params[:msg] unless params[:msg] and params[:msg].empty?
    @map = Response.find_by(map_id: params[:id])
    if params[:return] == "feedback"
Severity: Minor
Found in app/controllers/response_controller.rb - About 1 hr 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 calculate_all_penalties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def calculate_all_penalties(assignment_id)
    @all_penalties = {}
    @assignment = Assignment.find(assignment_id)
    calculate_for_participants = true unless @assignment.is_penalty_calculated
    Participant.where(parent_id: assignment_id).each do |participant|
Severity: Minor
Found in app/controllers/grades_controller.rb - About 1 hr 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

Block has too many lines. [38/25]
Open

    self.teams.each do |team|
      scores[:teams][index.to_s.to_sym] = {}
      scores[:teams][index.to_s.to_sym][:team] = team
      if self.varying_rubrics_by_round?
        grades_by_rounds = {}
Severity: Minor
Found in app/models/assignment.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [38/25]
Open

describe 'Airbrake-1781551925379466692' do
  let(:assignment) { build(:assignment, id: 1) }
  let(:assignment_questionaire1) { build(:assignment_questionaire1, assignment_id: 1, used_in_round: 2) }
  let(:assignment_due_date) do
    build(:assignment_due_date, parent_id: 1, due_at: '2011-11-11 11:11:11 UTC', deadline_name: 'Review',

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [38/25]
Open

FactoryBot.define do
  # Quiz Questionnaire is the main representation of a quiz
  # in the Expertiza model. It shares a one-to-many relationship
  # with QuizQuestion and QuizResponseMap, and foreign keys
  # to an AssignmentTeam. It is important to note that
Severity: Minor
Found in spec/factories/quiz_factory.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [38/25]
Open

  describe '#update' do
    context 'when something is wrong during response updating' do
      it 'raise an error and redirects to response#save page' do
        allow(review_response).to receive(:update_attribute).with('additional_comment', 'some comments').and_raise('ERROR!')
        params = {

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [38/25]
Open

  before(:each) do
    # assignment and topic
    create(:assignment,
           name: "Assignment1665",
           directory_path: "Assignment1665",

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method create_approved_user has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_approved_user
    requested_user = RequestedUser.find_by(id: params[:id])
    requested_user.status = params[:status]
    if requested_user.status.nil?
      flash[:error] = "Please Approve or Reject before submitting"
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

    Method import has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.import(row, _row_header, session, _id = nil)
        if row.length != 5
          raise ArgumentError, "Not enough items: expect 3 columns: your login name, your full name (first and last name, not seperated with the delimiter), and your email."
        end
        questionnaire = Questionnaire.find_by_id(_id)
    Severity: Minor
    Found in app/models/question.rb - About 1 hr to fix

      Method submit_file has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def submit_file
          participant = AssignmentParticipant.find(params[:id])
          return unless current_user_id?(participant.user_id)
          file = params[:uploaded_file]
          participant.team.set_student_directory_num
      Severity: Minor
      Found in app/controllers/submitted_content_controller.rb - About 1 hr to fix

        Method list has 34 lines of code (exceeds 25 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 1 hr to fix

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

              context 'when the deadline type is team formation and current assignment is team-based assignment' do
                it 'adds a delayed job and changes the # of DelayedJob by 2' do
                  allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'team_formation'))
                  Sidekiq::Testing.fake!
                  Sidekiq::RetrySet.new.clear
          Severity: Major
          Found in spec/models/assignment_form_spec.rb and 1 other location - About 1 hr to fix
          spec/models/assignment_form_spec.rb on lines 157..167

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

          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

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

              context 'when the deadline type is review' do
                it 'adds two delayed jobs and changes the # of DelayedJob by 2' do
                  allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'review'))
                  Sidekiq::Testing.fake!
                  Sidekiq::RetrySet.new.clear
          Severity: Major
          Found in spec/models/assignment_form_spec.rb and 1 other location - About 1 hr to fix
          spec/models/assignment_form_spec.rb on lines 171..181

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

          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

          Block has too many lines. [37/25]
          Open

                params[:question].keys.each do |qid|
                  @question = Question.find(qid)
                  @question.txt = params[:question][qid.to_sym][:txt]
                  @question.save
          
          

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

          Severity
          Category
          Status
          Source
          Language