fga-gpp-mds/2017.1-Escola-X

View on GitHub

Showing 3,213 of 3,213 total issues

SubjectsController#create performs a nil-check
Open

            if ( @teacher.nil? )
Severity: Minor
Found in app/controllers/subjects_controller.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

SessionsController#check_if_date_exits doesn't depend on instance state (maybe move it to another class?)
Open

  def check_if_date_exits(date)
Severity: Minor
Found in app/controllers/sessions_controller.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

SubjectsController#update performs a nil-check
Open

            if ( @teacher.nil? )
Severity: Minor
Found in app/controllers/subjects_controller.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

SessionsHelper#logged_in? performs a nil-check
Open

    if ( current_user.nil? )
      raise 'Not logged in'
    else
      !(current_user.nil?)
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

ReaderHelper#mountCurrentDate doesn't depend on instance state (maybe move it to another class?)
Open

    def mountCurrentDate() 
Severity: Minor
Found in app/helpers/reader_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

SchoolMissesHelper#give_fault_to_all_alumns doesn't depend on instance state (maybe move it to another class?)
Open

    def give_fault_to_all_alumns(date)
Severity: Minor
Found in app/helpers/school_misses_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

SessionsHelper#current_user performs a nil-check
Open

    if ( !@current_user.nil? )
      @current_user = @current_user
    else
      if ( !(@current_user = Employee.find_by_authorization_token(cookies[:authorization_token])).nil? )
        return @current_user
Severity: Minor
Found in app/helpers/sessions_helper.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Notification#get_date doesn't depend on instance state (maybe move it to another class?)
Open

  def get_date
Severity: Minor
Found in app/models/notification.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

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

  def update
    if ( is_principal? )
            @shifts = Shift.all
      @secretary = Secretary.find(params[:id])
      if @secretary.update secretary_params
Severity: Minor
Found in app/controllers/secretaries_controller.rb and 1 other location - About 25 mins to fix
app/controllers/teachers_controller.rb on lines 56..67

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

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

  def update
    if ( is_principal? )
      @shifts = Shift.all
      @teacher = Teacher.find(params[:id])
      if ( @teacher.update(teacher_params) )
Severity: Minor
Found in app/controllers/teachers_controller.rb and 1 other location - About 25 mins to fix
app/controllers/secretaries_controller.rb on lines 69..80

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

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

  def update
    if ( is_employee? )
      @strike = Strike.find(params[:id])
      if @strike.update(strike_params)
        flash[:notice] = "Advertência alterada com sucesso"
Severity: Minor
Found in app/controllers/strikes_controller.rb and 1 other location - About 20 mins to fix
app/controllers/suspensions_controller.rb on lines 79..89

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

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

    def update
        if( is_principal? )
            @suspension = Suspension.find(params[:id])
            if( @suspension.update(suspension_params) )
                flash[:notice] = "Suspensão alterada com sucesso"
Severity: Minor
Found in app/controllers/suspensions_controller.rb and 1 other location - About 20 mins to fix
app/controllers/strikes_controller.rb on lines 82..92

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

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

ErrorsController#error_500 has the name 'error_500'
Open

    def error_500
Severity: Minor
Found in app/controllers/errors_controller.rb by reek

An Uncommunicative Method Name is a method name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

ReaderController#mountCurrentDate has the variable name 'correctDate'
Open

         correctDate = year + SPACE_TRACE_SPACE + month + SPACE_TRACE_SPACE + day 
Severity: Minor
Found in app/controllers/reader_controller.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

ReaderController#mountCurrentDate has the name 'mountCurrentDate'
Open

    def mountCurrentDate() 
Severity: Minor
Found in app/controllers/reader_controller.rb by reek

An Uncommunicative Method Name is a method name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

ReaderHelper#mountCurrentDate has the name 'mountCurrentDate'
Open

    def mountCurrentDate() 
Severity: Minor
Found in app/helpers/reader_helper.rb by reek

An Uncommunicative Method Name is a method name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

ReaderHelper#mountCurrentDate has the variable name 'correctDate'
Open

         correctDate = year + SPACE_TRACE_SPACE + month + SPACE_TRACE_SPACE + day 
Severity: Minor
Found in app/helpers/reader_helper.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Alumn#self.current= has the parameter name 'a'
Open

  def self.current=(a)
Severity: Minor
Found in app/models/alumn.rb by reek

An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Missing top-level class documentation comment.
Open

class ClassroomSubject < ApplicationRecord
Severity: Minor
Found in app/models/classroom_subject.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

Missing space after #.
Open

#Description: Validates alumn's grade attributes
Severity: Minor
Found in app/models/grade.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
Severity
Category
Status
Source
Language