njazari/sef-founderwall

View on GitHub

Showing 1,083 of 1,083 total issues

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

  def change
    create_table :users do |t|
      ## Database authenticatable
      t.boolean :admin
      t.string :email,              null: false, default: ""

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 update is too high. [19.95/15]
Open

    def update
        @dedication = Dedication.find(params[:id])
        @dedication.dedication = params[:dedication][:dedication]
        @dedication.status = params[:dedication][:status]
        if params[:publish]

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. [19.62/15]
Open

    def show
        @dedication = Dedication.find_by_id(params[:id])
        @donor_logged_in = false
        if current_user
            @donor_logged_in = current_user.donor == @dedication.donor || current_user.admin?

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. [14/10]
Open

    def show
        @donor = Donor.find_by_id(params[:id])
        if @donor.nil? or @donor.status == false
            @error = 'Donor'
            render 'errors/status'

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 index is too high. [18.68/15]
Open

    def index
        @dedications = Dedication.visible
        
        @filterrific = initialize_filterrific(
            Dedication.visible, 

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. [13/10]
Open

  def change
    create_table :hospitals do |t|
      t.string :name
      t.string :city
      t.integer :surgeries

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.

Perceived complexity for create is too high. [9/7]
Open

  def create
    @donor = Donor.find(params[:user][:donor_id])
    if @donor.user != nil
      flash[:error] = "There is already an account associated with this email. Log in or contact an admin."
      redirect_to '/users/sign_up?donor_id=' + params[:user][:donor_id].to_s + '&secret=' + params[:user][:secret]

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

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

    def show
        @dedication = Dedication.find_by_id(params[:id])
        @donor_logged_in = false
        if current_user
            @donor_logged_in = current_user.donor == @dedication.donor || current_user.admin?

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 show is too high. [17.92/15]
Open

    def show
        @donor = Donor.find_by_id(params[:id])
        if @donor.nil? or @donor.status == false
            @error = 'Donor'
            render 'errors/status'

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 dedications_by_tier(published)
        dbt = Hash.new
        if published
            Dedication.tiers.each do |tier|
                dbt[tier] = Dedication.where(:donor => self.id, :tier => tier, :published => published)
Severity: Minor
Found in app/models/donor.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.

Perceived complexity for create is too high. [8/7]
Open

    def create
      begin
        @contact_form = ContactForm.new(params[:contact_form])
        @spam = false
        if not @contact_form.nickname.empty?

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

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

  config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
    b.use :html5
    b.use :placeholder
    b.optional :maxlength
    b.optional :pattern
Severity: Major
Found in config/initializers/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
config/initializers/simple_form_bootstrap.rb on lines 7..19

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

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

  config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
    b.use :html5
    b.use :placeholder
    b.optional :maxlength
    b.optional :pattern
Severity: Major
Found in config/initializers/simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
config/initializers/simple_form_bootstrap.rb on lines 111..123

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

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

  def create
    @donor = Donor.find(params[:user][:donor_id])
    if @donor.user != nil
      flash[:error] = "There is already an account associated with this email. Log in or contact an admin."
      redirect_to '/users/sign_up?donor_id=' + params[:user][:donor_id].to_s + '&secret=' + params[:user][:secret]
Severity: Minor
Found in app/controllers/users/registrations_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

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

  if not Donor.exists?(donor[:id])
    Donor.create!(donor)
  elsif Donor.find(donor[:id]).status.nil?
    d = Donor.find(donor[:id])
    d.update(status: donor[:status])
Severity: Major
Found in db/seeds.rb and 1 other location - About 1 hr to fix
db/seeds.rb on lines 61..69

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

  if not Dedication.exists?(dedication[:id])
    Dedication.create!(dedication)
  elsif Dedication.find(dedication[:id]).status.nil?
    d = Dedication.find(dedication[:id])
    d.update(status: dedication[:status])
Severity: Major
Found in db/seeds.rb and 1 other location - About 1 hr to fix
db/seeds.rb on lines 33..41

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

  def create
    @donor = Donor.find(params[:user][:donor_id])
    if @donor.user != nil
      flash[:error] = "There is already an account associated with this email. Log in or contact an admin."
      redirect_to '/users/sign_up?donor_id=' + params[:user][:donor_id].to_s + '&secret=' + params[:user][:secret]
Severity: Minor
Found in app/controllers/users/registrations_controller.rb - About 1 hr to fix

    Method create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def create
          begin
            @contact_form = ContactForm.new(params[:contact_form])
            @spam = false
            if not @contact_form.nickname.empty?
    Severity: Minor
    Found in app/controllers/contact_forms_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

    Denial of Service Vulnerability in Action View
    Open

        actionview (4.2.6)
    Severity: Critical
    Found in Gemfile.lock by bundler-audit

    Advisory: CVE-2019-5419

    Criticality: High

    URL: https://groups.google.com/forum/#!topic/rubyonrails-security/GN7w9fFAQeI

    Solution: upgrade to >= 6.0.0.beta3, >= 5.2.2.1, ~> 5.2.2, >= 5.1.6.2, ~> 5.1.6, >= 5.0.7.2, ~> 5.0.7, >= 4.2.11.1, ~> 4.2.11

    Potential remote code execution of user-provided local names in ActionView
    Open

        actionview (4.2.6)
    Severity: Critical
    Found in Gemfile.lock by bundler-audit

    Advisory: CVE-2020-8163

    Criticality: High

    URL: https://groups.google.com/forum/#!topic/rubyonrails-security/hWuKcHyoKh0

    Solution: upgrade to >= 4.2.11.2

    Severity
    Category
    Status
    Source
    Language