ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Assignment Branch Condition size for update is too high. [51.43/15]
Open

  def update
    @penalty_policy = LatePolicy.find(params[:id])
    invalid_penalty_per_unit = params[:late_policy][:max_penalty].to_i < params[:late_policy][:penalty_per_unit].to_i
    flash[:error] = "The maximum penalty cannot be less than penalty per unit." if invalid_penalty_per_unit
    same_policy_name = false

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method import_from_hash has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

  def import_from_hash(session, params)
    contents_hash = eval(params[:contents_hash])
    if params[:model] == "AssignmentTeam" or params[:model] == "CourseTeam"
      # contents_hash = eval(params[:contents_hash])
      @header_integrated_body = hash_rows_with_headers(contents_hash[:header], contents_hash[:body])
Severity: Minor
Found in app/controllers/import_file_controller.rb - About 5 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

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

  context "#create" do
    before(:each) do
      allow(User).to receive(:find).with(3).and_return(admin)
    end
    it 'save successfully with email as name' do

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.

Assignment Branch Condition size for feedback_response_report is too high. [49.53/15]
Open

  def self.feedback_response_report(id, _type)
    # Example query
    # SELECT distinct reviewer_id FROM response_maps where type = 'FeedbackResponseMap' and
    # reviewed_object_id in (select id from responses where
    # map_id in (select id from response_maps where reviewed_object_id = 722 and type = 'ReviewResponseMap'))
Severity: Minor
Found in app/models/feedback_response_map.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for display_directory_tree is too high. [49.74/15]
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

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

describe 'new user request' do
  before(:each) do
    create(:role_of_student)
    create(:role_of_instructor)
    create(:role_of_administrator)

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. [88/25]
Open

describe "peer review testing" do
  before(:each) do
    # create assignment and topic
    create(:assignment, name: "TestAssignment", directory_path: "TestAssignment")
    create_list(:participant, 3)

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.

Assignment Branch Condition size for create_approved_user is too high. [48.48/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

  describe '#update' do
    context 'when params does not have key :assignment_form' do
      context 'when assignment is saved successfully' do
        it 'shows a note flash message and redirects to tree_display#index page' do
          allow(assignment).to receive(:save).and_return(true)

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.

Assignment Branch Condition size for edit is too high. [46.73/15]
Open

  def edit
    quiz_question_choices = QuizQuestionChoice.where(question_id: self.id)

    html = '<tr><td>'
    html += '<textarea cols="100" name="question[' + self.id.to_s + '][txt]" '
Severity: Minor
Found in app/models/true_false.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method calculate_score has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def calculate_score(map, response)
    questionnaire = Questionnaire.find(map.reviewed_object_id)
    scores = []
    valid = true
    questions = Question.where(questionnaire_id: questionnaire.id)
Severity: Minor
Found in app/controllers/student_quizzes_controller.rb - About 5 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

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

describe "review mapping" do
  before(:each) do
    @assignment = create(:assignment, name: "automatic review mapping test", max_team_size: 4)
    create(:assignment_node)
    create(:deadline_type, name: "submission")

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.

Assignment Branch Condition size for contributor_to_review is too high. [45.78/15]
Open

  def contributor_to_review(reviewer, topic)
    raise 'Please select a topic' if topics? && topic.nil?
    raise 'This assignment does not have topics' if !topics? && topic
    # This condition might happen if the reviewer waited too much time in the
    # select topic page and other students have already selected this topic.
Severity: Minor
Found in app/models/review_assignment.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for import is too high. [45.81/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for add is too high. [45.09/15]
Open

  def add
    curr_object = Object.const_get(params[:model]).find(params[:id]) if Participant::PARTICIPANT_TYPES.include? params[:model]
    begin
      permissions = Participant.get_permissions(params[:authorization])
      can_submit = permissions[:can_submit]

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [45.22/15]
Open

  def update
    matching_teams = AssignmentTeam.where name: params[:team][:name], parent_id: team.parent_id
    if matching_teams.length.zero?
      if team.update_attribute('name', params[:team][:name])
        team_created_successfully

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for show is too high. [45.49/15]
Open

  def show
    @id = params[:id]
    @model = params[:model]
    @options = params[:options]
    @delimiter = get_delimiter(params)

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [45.12/15]
Open

  def update
    render nothing: true unless action_allowed?
    # the response to be updated
    @response = Response.find(params[:id])
    msg = ""

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for build_tone_analysis_heatmap is too high. [45.67/15]
Open

  def build_tone_analysis_heatmap

    @heatmap_urls = []
    keys = @review_final_versions.keys

Severity: Minor
Found in app/controllers/popup_controller.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for create is too high. [45.28/15]
Open

  def create
    params[:url] = params[:url].gsub!(/http:\/\//, "") if params[:url].start_with?('http://')
    params[:url] = params[:url].gsub!(/https:\/\//, "") if params[:url].start_with?('https://')
    begin
      Bookmark.create(url: params[:url], title: params[:title], description: params[:description], user_id: session[:user].id, topic_id: params[:topic_id])

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Severity
Category
Status
Source
Language