ece517-p3/expertiza

View on GitHub

Showing 2,813 of 2,813 total issues

Method view has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def view
    # View will check if send_invs and recieved_invs are set before showing
    # only the owner should be able to see those.
    return unless current_user_id? student.user_id

Severity: Minor
Found in app/controllers/student_teams_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 list_sub_directories has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def list_sub_directories(file, participant)
    index = 0
    ret = "<ul id= 'subdir." + index.to_s + "." + index.to_s + "'>"
    Dir.foreach(file) do |path|
      next if path == "." or path == ".." or path == ".svn"
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 contributor_for_quiz has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def contributor_for_quiz(reviewer, topic)
    raise "Please select a topic." if topics? and topic.nil?
    raise "This assignment does not have topics." if !topics? and topic

    # This condition might happen if the reviewer/quiz taker waited too much time in the
Severity: Minor
Found in app/models/quiz_assignment.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 merge_bids_from_different_previous_teams has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_bids_from_different_previous_teams(assignment, team_id, user_ids, priority_info)
    # Select data from `priority_info` variable that only related to team members in current team and transpose it.
    # For example, below matrix shows 4 topics (key) and correponding priorities given by 3 team members (value).
    # {
    #   1: [1, 2, 3],
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

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

  def self.export_fields(options)
    fields = []
    fields.push("name", "full name", "email") if options["personal_details"] == "true"
    fields.push("role") if options["role"] == "true"
    fields.push("parent") if options["parent"] == "true"
Severity: Major
Found in app/models/user.rb and 1 other location - About 1 hr to fix
app/models/participant.rb on lines 147..154

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

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 edit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def edit
    assign_instance_vars
    @prev = Response.where(map_id: @map.id)
    @review_scores = @prev.to_a
    if @prev.present?
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

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

  def self.export_fields(options)
    fields = []
    fields.push("name", "full name", "email") if options["personal_details"] == "true"
    fields.push("role") if options["role"] == "true"
    fields.push("parent") if options["parent"] == "true"
Severity: Major
Found in app/models/participant.rb and 1 other location - About 1 hr to fix
app/models/user.rb on lines 253..260

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

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

    CSV::Reader.parse(file) do |row|
      unless row.empty?
        i = 0
        score = questionnaire.max_question_score
        q = Question.new
Severity: Minor
Found in app/helpers/questionnaire_helper.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. [36/25]
Open

      context 'when an assignment_participant can be found' do
        before(:each) do
          allow(AssignmentParticipant).to receive(:exists?).with(user_id: 8, parent_id: '1').and_return(true)
        end

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

describe "airbrake-1517247902792549741" do
  it "cannot access to '/tree_display/list' if not login" do
    visit '/tree_display/list'
    expect(page).to have_current_path('/auth/failure')
    expect(page).not_to have_content('Manage content')

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

  describe 'one student who signup for a topic should send an inviatation to the other student who has no topic' do
    before(:each) do
      user = User.find_by(name: "student2064")
      stub_current_user(user, user.role.name, user.role)
      visit '/student_task/list'
Severity: Minor
Found in spec/features/team_creation_spec.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.

Function handleUserClick has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    handleUserClick: function(colName, order) {
      var tmpData = this.state.tableData
      tmpData.sort(function(a, b) {
        var a_val = eval("a."+colName)
        var b_val = eval("b."+colName)
Severity: Minor
Found in app/assets/javascripts/tree_display.jsx - About 1 hr to fix

    Method assignment_questionnaire has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def assignment_questionnaire(assignment, type, number)
        questionnaire = assignment.questionnaires.find_by(type: type)
    
        if questionnaire.nil?
          default_weight = {}
    Severity: Minor
    Found in app/helpers/assignment_helper.rb - About 1 hr to fix

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

        factory :instructor, class: Instructor do
          name 'instructor6'
          role { Role.where(name: 'Instructor').first || association(:role_of_instructor) }
          password 'password'
          password_confirmation 'password'
      Severity: Major
      Found in spec/factories/factories.rb and 1 other location - About 1 hr to fix
      spec/factories/factories.rb on lines 125..144

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

      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

        it "is able to add and edit questions to a course survey" do
          survey_name = 'Course Survey Questionnaire 1'
          deploy_course_survey(@next_day, @next_to_next_day, survey_name)
          survey_questionnaire = Questionnaire.where(name: survey_name).first
          # adding some questions for the deployed survey
      Severity: Major
      Found in spec/features/course_survey_spec.rb and 1 other location - About 1 hr to fix
      spec/features/global_survey_spec.rb on lines 53..66

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

      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

        factory :teaching_assistant, class: Ta do
          name 'teaching_assistant5888'
          role { Role.where(name: 'Teaching Assistant').first || association(:role_of_teaching_assistant) }
          password 'password'
          password_confirmation 'password'
      Severity: Major
      Found in spec/factories/factories.rb and 1 other location - About 1 hr to fix
      spec/factories/factories.rb on lines 103..122

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

      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

        it "is able to add and edit questions to a course survey" do
          survey_name = 'Global Survey Questionnaire 1'
          deploy_global_survey(@next_day, @next_to_next_day, survey_name)
          survey_questionnaire = Questionnaire.where(name: survey_name).first
      
      
      Severity: Major
      Found in spec/features/global_survey_spec.rb and 1 other location - About 1 hr to fix
      spec/features/course_survey_spec.rb on lines 52..64

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

      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 assignment_tagging_progress has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def assignment_tagging_progress
          teams = Team.where(parent_id: self.assignment_id)
          questions = Question.where(questionnaire_id: self.questionnaire.id, type: self.question_type)
          questions_ids = questions.map(&:id)
          user_answer_tagging = []
      Severity: Minor
      Found in app/models/tag_prompt_deployment.rb - About 1 hr to fix

        Method create has 30 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: Minor
        Found in app/controllers/teams_users_controller.rb - About 1 hr to fix

          Method four_node_cycles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def four_node_cycles(assignment_participant)
              collusion_cycles = []
              assignment_participant.reviewers.each do |ap1|
                ap1.reviewers.each do |ap2|
                  ap2.reviewers.each do |ap3|
          Severity: Minor
          Found in app/models/collusion_cycle.rb - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language