mingujo/UCBerkeley_Housing

View on GitHub

Showing 31 of 31 total issues

Method destroy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @event = Event.find_by_id(params[:id])
    if params[:delete_all] == "true"
      events = Event.where(:event_series_id => @event.event_series_id)
      for event in events
Severity: Minor
Found in app/controllers/events_controller.rb - About 2 hrs 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 make_event_json has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def make_event_json(events, ca_id=nil)
        lst = []
        events.each do |event|
            if ca_id and event.ca_id != ca_id.to_i
                next
Severity: Minor
Found in app/helpers/events_helper.rb - About 2 hrs 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 detect_change_send_email has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def detect_change_send_email(info_list)
    str_date = info_list[0][0].split(" ")[0]
    str_date = str_date.split('/')
    str_date = str_date[1]+'/'+str_date[0]+'/'+str_date[2]
    # ONE SAD PATH: if there is no ca and scheduler puts the client name, it will error out
Severity: Minor
Found in app/helpers/fetch_sheets.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 create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if params[:event][:period] == "Does not repeat"
      event = Event.new(event_params)
    else
      event = EventSeries.new(event_params)
Severity: Minor
Found in app/controllers/events_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

    describe "cancellation_email(guy_CA)" do
        before :all do
            @mail = SchedulerMailer.send_email(@temp_guy.id, @temp_ts.starttime, "cancellation")
        end

Severity: Major
Found in spec/mailers/scheduler_mailer_spec.rb and 1 other location - About 1 hr to fix
spec/mailers/scheduler_mailer_spec.rb on lines 27..46

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

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

    describe "new_schedule_notification_email(guy_CA)" do
        before :all do
            @mail = SchedulerMailer.send_email(@temp_guy.id, @temp_ts.starttime, "new_schedule")
        end

Severity: Major
Found in spec/mailers/scheduler_mailer_spec.rb and 1 other location - About 1 hr to fix
spec/mailers/scheduler_mailer_spec.rb on lines 51..70

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

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

  def update
    @event = Event.find_by_id(params[:id])
    ts = Timeslot.find_by_starttime_and_ca_id(@event.start_time, @event.ca_id)
    @event.attributes = event_params
    if @event.attributes["end_time"] - @event.attributes["start_time"] != @@THIRTY_MIN
Severity: Minor
Found in app/controllers/events_controller.rb - About 1 hr to fix

    Method path_to has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def path_to(page_name)
        case page_name
    
        when /^the home\s?page$/
          '/'
    Severity: Minor
    Found in features/support/paths.rb - About 1 hr to fix

      Method update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @event = Event.find_by_id(params[:id])
          ts = Timeslot.find_by_starttime_and_ca_id(@event.start_time, @event.ca_id)
          @event.attributes = event_params
          if @event.attributes["end_time"] - @event.attributes["start_time"] != @@THIRTY_MIN
      Severity: Minor
      Found in app/controllers/events_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 create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          if params[:event][:period] == "Does not repeat"
            event = Event.new(event_params)
          else
            event = EventSeries.new(event_params)
      Severity: Minor
      Found in app/controllers/events_controller.rb - About 1 hr to fix

        Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def create
                year = params[:ca][:year].to_i
                month = params[:ca][:month].to_i
                if spreadsheet_exists(month, year)
                    flash[:error] = "Spreadsheet for this month and year already exists"
        Severity: Minor
        Found in app/controllers/spreadsheets_controller.rb - About 1 hr to fix

          Method create_events_until_end_time has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create_events_until_end_time()
              next_month = (start_time.month.to_i + 1).to_s
              end_recur = Time.parse(start_time.year.to_s+"-"+next_month+"-"+1.to_s)
              st = start_time
              et = end_time
          Severity: Minor
          Found in app/models/event_series.rb - About 1 hr to fix

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

                  it "creates a new Event" do
                    expect {
                      post :create, {:event => {
                      'start_time(1i)' => 2016, 
                      'start_time(2i)' => 11,
            Severity: Major
            Found in spec/controllers/events_controller_spec.rb and 2 other locations - About 50 mins to fix
            spec/controllers/events_controller_spec.rb on lines 114..131
            spec/controllers/events_controller_spec.rb on lines 134..151

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

            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

                  it "creates a new Event with start time is larger than end time" do
                    expect {
                      post :create, {:event => {
                      'start_time(1i)' => 2016, 
                      'start_time(2i)' => 11,
            Severity: Major
            Found in spec/controllers/events_controller_spec.rb and 2 other locations - About 50 mins to fix
            spec/controllers/events_controller_spec.rb on lines 94..111
            spec/controllers/events_controller_spec.rb on lines 114..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 42.

            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

                  it "attempts to create an existing Event" do
                    expect {
                      post :create, {:event => {
                      'start_time(1i)' => 2016, 
                      'start_time(2i)' => 11,
            Severity: Major
            Found in spec/controllers/events_controller_spec.rb and 2 other locations - About 50 mins to fix
            spec/controllers/events_controller_spec.rb on lines 94..111
            spec/controllers/events_controller_spec.rb on lines 134..151

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

            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_ts has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def update_ts(ts, client_name, phone_number, apt_number, current_tenant)
            Severity: Minor
            Found in app/helpers/fetch_sheets.rb - About 35 mins to fix

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

              Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
                with_scope(parent) do
                  field = find_field(field)
                  field_value = (field.tag_name == 'textarea') ? field.text : field.value
                  if field_value.respond_to? :should
              Severity: Minor
              Found in features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
              features/step_definitions/web_steps.rb on lines 153..160

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

              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

              Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
                with_scope(parent) do
                  field = find_field(field)
                  field_value = (field.tag_name == 'textarea') ? field.text : field.value
                  if field_value.respond_to? :should_not
              Severity: Minor
              Found in features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
              features/step_definitions/web_steps.rb on lines 141..148

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

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

                def create_events_until_end_time()
                  next_month = (start_time.month.to_i + 1).to_s
                  end_recur = Time.parse(start_time.year.to_s+"-"+next_month+"-"+1.to_s)
                  st = start_time
                  et = end_time
              Severity: Minor
              Found in app/models/event_series.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

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

                  if params[:ca][:name] == "" or params[:ca][:email] == ""  or params[:ca][:phone_number] == ""
                    flash[:error] = "Please do not leave any fields blank."
                    redirect_to edit_ca_path
                    return
                  end
              Severity: Minor
              Found in app/controllers/cas_controller.rb and 1 other location - About 30 mins to fix
              app/controllers/cas_controller.rb on lines 41..45

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

              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

              Severity
              Category
              Status
              Source
              Language