TeaWithStrangers/tws-on-rails

View on GitHub

Showing 35 of 35 total issues

Method newsletter_unsubscribe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.newsletter_unsubscribe(email)
    if @sg
      # Make 3 attempts to unsubscribe
      for attempt in 1..3 do
        if add_to_unsubscribe_group(email)
Severity: Minor
Found in app/services/send_grid_list.rb - About 45 mins 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 get_segment_recipients has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_segment_recipients(segment_id)
    if @sg
      puts 'Fetching segment %s' % [segment_id]
      query_params = {page: 1, page_size: 1000}

Severity: Minor
Found in app/services/send_grid_list.rb - About 45 mins 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 find_new_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_new_status(user)
    tea_times = user.tea_times.completed.order('start_time asc').to_a
    most_recent = tea_times.last
    user.send_drip_email(most_recent)
    commitment = user.commitment
Severity: Minor
Found in app/jobs/refresh_host_activity_status.rb - About 35 mins 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 jfdi_signup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def jfdi_signup
    # Querystring params (all optional):
    # - redirect_to_tt: integer - Set the tea time to redirect to after signup
    # - city_id: integer - Set the default selected city in home city dropdown
    # - remind_next_month: (any) - Pass a querystring param to the registration
Severity: Minor
Found in app/controllers/static_controller.rb - About 35 mins 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 commitment_overview= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def commitment_overview=(overview)
    if overview.to_s != HostDetail::REGULAR_COMMITMENT.to_s
      if commitment.nil?
        if overview.to_s == HostDetail::NO_COMMITMENT.to_s
          HostMailer.commitment_intro(id).deliver_later
Severity: Minor
Found in app/models/user.rb - About 35 mins 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 transform_tea_times has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def transform_tea_times(tea_times)
    # For each available city, create a hash entry and an empty list
    # of tea times
    tea_times_by_city = Hash.new

Severity: Minor
Found in app/controllers/tea_times_controller.rb - About 25 mins 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 3 locations. Consider refactoring.
Open

  def commitment_intro(host_id)
    @host = User.find_by_id(host_id)
    cancel_delivery unless @host
    cancel_delivery if @host.commitment_overview == HostDetail::INACTIVE_COMMITMENT
     
Severity: Minor
Found in app/mailers/host_mailer.rb and 2 other locations - About 25 mins to fix
app/mailers/host_mailer.rb on lines 86..94
app/mailers/host_mailer.rb on lines 98..106

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

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

  def update
    if params[:approval_action]
      approver = CityApprover.new(@city.id)
      case params[:approval_action]
      when "merge"
Severity: Minor
Found in app/controllers/cities_controller.rb - About 25 mins 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

Function getInterests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

var getInterests = function() {
  $.get('/api/v1/users/self/interests', function(user_info) {
    if (!user_info) { return; }

    if (user_info.leading) {
Severity: Minor
Found in app/assets/javascripts/cities.js - About 25 mins 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 delete_user_by_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.delete_user_by_email(email)
    if @sg
      user_response = @sg.client.contactdb.recipients.search.get(query_params: {email: email})
      if user_response.status_code == "200"
        resp = JSON.parse(user_response.body)
Severity: Minor
Found in app/services/send_grid_list.rb - About 25 mins 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 inactive_host_posted has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def inactive_host_posted(host_id)
    @host = User.find_by_id(host_id)
    cancel_delivery unless @host
    cancel_delivery unless @host.commitment_overview == HostDetail::INACTIVE_COMMITMENT
    cancel_delivery unless @host.tea_times.future.pending.any?
Severity: Minor
Found in app/mailers/host_mailer.rb - About 25 mins 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 3 locations. Consider refactoring.
Open

  def pause(host_id)
    @host = User.find_by_id(host_id)
    cancel_delivery unless @host
    cancel_delivery unless @host.commitment_overview == HostDetail::INACTIVE_COMMITMENT

Severity: Minor
Found in app/mailers/host_mailer.rb and 2 other locations - About 25 mins to fix
app/mailers/host_mailer.rb on lines 86..94
app/mailers/host_mailer.rb on lines 123..131

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

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 3 locations. Consider refactoring.
Open

  def no_commitment_drip_reminder(host_id)
    @host = User.find_by_id(host_id)
    cancel_delivery unless @host
    cancel_delivery unless @host.commitment_overview == HostDetail::NO_COMMITMENT

Severity: Minor
Found in app/mailers/host_mailer.rb and 2 other locations - About 25 mins to fix
app/mailers/host_mailer.rb on lines 98..106
app/mailers/host_mailer.rb on lines 123..131

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

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

  def custom_first_reminder(attendance_id)
    sendgrid_category "Tea Time Reminder"

    @attendance = Attendance.find(attendance_id)
    cancel_delivery unless @attendance
Severity: Minor
Found in app/mailers/attendance_mailer.rb - About 25 mins 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 flake! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def flake!(opts = {})
    unless flake?
      if !tea_time.spots_remaining?
        tea_time.send_waitlist_notifications
      end
Severity: Minor
Found in app/models/attendance.rb - About 25 mins 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

Severity
Category
Status
Source
Language