yippie-io/iUPB

View on GitHub

Showing 49 of 49 total issues

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

    settings = { container: window
                 , currentPage: 1
                 , distance: 100
                 , pagination: '.pagination'
                 , params: {}
Severity: Minor
Found in app/assets/javascripts/libs/jquery.pageless.js and 1 other location - About 35 mins to fix
app/assets/javascripts/libs/jquery.pageless.js on lines 64..72

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

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

  def recurring_end_greater_than_start_time
      if recurring
        if recurring_end
          errors.add(:recurring_end, "can't be set before start time") if recurring_end < start_time.to_date
        else
Severity: Minor
Found in app/models/event.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 parsed_side_dishes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def parsed_side_dishes(locale = nil)
    result = {}
      if self[:side_dishes].respond_to?(:each)
        self[:side_dishes].each do |key, val|
        result[key] = JSON.parse(val) if val
Severity: Minor
Found in app/models/menu.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 update_next_class_information! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update_next_class_information!
    min_interval = 100.days
    self.course_data.each do |data|
      date = data["date"]
      time_from_key = "time_from"
Severity: Minor
Found in app/models/course.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 extract_youtube_videos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def extract_youtube_videos (html_string)
    urls = URI.extract html_string
    urls_converted = urls.uniq.map do |url| 
      if url.blank? 
        nil 
Severity: Minor
Found in app/controllers/ads_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

Method _name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def _name
    if self.course and !self.custom
      return self.course.title if self.course.course_type === "course"
      return self.course.group_title if self.course.course_type === "group"
    end
Severity: Minor
Found in app/models/event.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 update_recurring has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update_recurring # untested. might be an infinite loop. TODO
    if self.recurring or self.parent_event
      (self.recurring ? self : self.parent_event).children_events.each do |e|
        e.update_attributes(name: self.name, start_time: self.start_time, end_time: self.end_time, location: self.location)
      end
Severity: Minor
Found in app/models/event.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

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

      @menus = @restaurant.menus.where(date: @today.to_time.midnight).where(name: "Mittagessen").to_a + @restaurant.menus.where(date: @today.to_time.midnight).where(name: "Abendessen").to_a
Severity: Minor
Found in app/controllers/restaurants_controller.rb and 1 other location - About 20 mins to fix
app/controllers/restaurants_controller.rb on lines 26..26

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

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

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

    @menus = @restaurant.menus.where(date: @today.to_time.midnight).where(name: "Mittagessen").to_a + @restaurant.menus.where(date: @today.to_time.midnight).where(name: "Abendessen").to_a
Severity: Minor
Found in app/controllers/restaurants_controller.rb and 1 other location - About 20 mins to fix
app/controllers/restaurants_controller.rb on lines 30..30

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

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