expertiza/expertiza

View on GitHub
app/helpers/participants_helper.rb

Summary

Maintainability
A
1 hr
Test Coverage
F
35%

Module has too many lines. [104/100]
Open

module ParticipantsHelper
  # separates the file into the necessary elements to create a new user
  def self.upload_users(filename, session, params, home_page)
    users = []
    File.open(filename, 'r') do |infile|
Severity: Minor
Found in app/helpers/participants_helper.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [29/10]
Open

  def participant_permissions(authorization)
    can_submit = true
    can_review = true
    can_take_quiz = true
  #E2351 pass duty field to match implementation
Severity: Minor
Found in app/helpers/participants_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for participant_permissions is too high. [21.38/15]
Open

  def participant_permissions(authorization)
    can_submit = true
    can_review = true
    can_take_quiz = true
  #E2351 pass duty field to match implementation
Severity: Minor
Found in app/helpers/participants_helper.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 has too many lines. [11/10]
Open

  def self.get_config
    config = {}
    cfgdir = Rails.root + '/config/'
    File.open(cfgdir + 'roster_config', 'r') do |infile|
      while (line = infile.gets)
Severity: Minor
Found in app/helpers/participants_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for define_user is too high. [16.03/15]
Open

  def self.define_user(attrs, session, params, home_page)
    user = User.find_by(name: attrs['name'])
    user = create_new_user(attrs, session) if user.nil?
    if !params[:course_id].nil?
      participant = add_user_to_course(params, user)
Severity: Minor
Found in app/helpers/participants_helper.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 define_attributes is too high. [15.81/15]
Open

  def self.define_attributes(line_split, config)
    attributes = {}
    attributes['role_id'] = Role.find_by name: 'Student'
    attributes['name'] = line_split[config['name'].to_i]
    attributes['fullname'] = config['fullname']
Severity: Minor
Found in app/helpers/participants_helper.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 participant_permissions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def participant_permissions(authorization)
    can_submit = true
    can_review = true
    can_take_quiz = true
  #E2351 pass duty field to match implementation
Severity: Minor
Found in app/helpers/participants_helper.rb - About 1 hr to fix

    Incorrect indentation detected (column 2 instead of 6).
    Open

      #end 2351 changes
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cops checks the indentation of comments.

    Example:

    # bad
      # comment here
    def method_name
    end
    
      # comment here
    a = 'hello'
    
    # yet another comment
      if true
        true
      end
    
    # good
    # comment here
    def method_name
    end
    
    # comment here
    a = 'hello'
    
    # yet another comment
    if true
      true
    end

    Incorrect indentation detected (column 2 instead of 6).
    Open

      #maintained as a boolean like other permissions
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cops checks the indentation of comments.

    Example:

    # bad
      # comment here
    def method_name
    end
    
      # comment here
    a = 'hello'
    
    # yet another comment
      if true
        true
      end
    
    # good
    # comment here
    def method_name
    end
    
    # comment here
    a = 'hello'
    
    # yet another comment
    if true
      true
    end

    Prefer ranges when generating random numbers instead of integers with offsets.
    Open

        attributes['password'] = (0...8).map { (65 + rand(26)).chr }.join
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks for the use of randomly generated numbers, added/subtracted with integer literals, as well as those with Integer#succ and Integer#pred methods. Prefer using ranges instead, as it clearly states the intentions.

    Example:

    # bad
    rand(6) + 1
    1 + rand(6)
    rand(6) - 1
    1 - rand(6)
    rand(6).succ
    rand(6).pred
    Random.rand(6) + 1
    Kernel.rand(6) + 1
    rand(0..5) + 1
    
    # good
    rand(1..6)
    rand(1...7)

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if AssignmentParticipant.where('user_id = ? AND parent_id = ?', user.id, assignment.id).empty?
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if CourseParticipant.where('user_id = ? AND parent_id = ?', user.id, params[:course_id]).empty?
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Missing space after #.
    Open

      #maintained as a boolean like other permissions
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

        if line_split[0] == ident
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Missing space after #.
    Open

      #E2351 pass duty field to match implementation
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Missing space after #.
    Open

      #end 2351 changes
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Do not prefix reader method names with get_.
    Open

      def self.get_config
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop makes sure that accessor methods are named properly.

    Example:

    # bad
    def set_attribute(value)
    end
    
    # good
    def attribute=(value)
    end
    
    # bad
    def get_attribute
    end
    
    # good
    def attribute
    end

    Incorrect indentation detected (column 2 instead of 4).
    Open

      #E2351 pass duty field to match implementation
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cops checks the indentation of comments.

    Example:

    # bad
      # comment here
    def method_name
    end
    
      # comment here
    a = 'hello'
    
    # yet another comment
      if true
        true
      end
    
    # good
    # comment here
    def method_name
    end
    
    # comment here
    a = 'hello'
    
    # yet another comment
    if true
      true
    end

    Missing space after #.
    Open

      #E2351 - adding a 4th option for mentor, permissions are same as participant but has additional permission 'can_mentor'
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Missing top-level module documentation comment.
    Open

    module ParticipantsHelper
    Severity: Minor
    Found in app/helpers/participants_helper.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    There are no issues that match your filters.

    Category
    Status