ikuseiGmbH/smart-village-app-cms

View on GitHub

Showing 1,158 of 1,254 total issues

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

  def update
    construction_id = params[:id]

    query = create_or_update_mutation(true)
    # logger.warn(query)
Severity: Major
Found in app/controllers/constructions_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/jobs_controller.rb on lines 132..144
app/controllers/offers_controller.rb on lines 117..129
app/controllers/point_of_interests_controller.rb on lines 187..199
app/controllers/tours_controller.rb on lines 164..176

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

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

      if @tour_params["media_contents"].present?
        media_contents = []
        @tour_params["media_contents"].each do |_key, media_content|
          next if media_content.blank?

Severity: Minor
Found in app/controllers/tours_controller.rb and 1 other location - About 30 mins to fix
app/controllers/point_of_interests_controller.rb on lines 307..314

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

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

  def destroy
    results = @smart_village.query <<~GRAPHQL
      mutation {
        destroyRecord(
          id: #{params["id"]},
Severity: Major
Found in app/controllers/defect_reports_controller.rb and 5 other locations - About 30 mins to fix
app/controllers/deadlines_controller.rb on lines 135..154
app/controllers/noticeboards_controller.rb on lines 49..68
app/controllers/static_contents_controller.rb on lines 74..93
app/controllers/surveys_controller.rb on lines 78..97
app/controllers/tours_controller.rb on lines 179..198

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

Complex method EventsController#copy_event_and_set_invisibility (21.3)
Open

  def copy_event_and_set_invisibility
    query = create_update_or_copy_mutation(is_copy: true)
    begin
      results = @smart_village.query query
      @smart_village.query <<~GRAPHQL
Severity: Minor
Found in app/controllers/events_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method StaticContentsController#update (21.3)
Open

  def update
    static_content_name = params[:name]
    static_content_version = params[:static_content][:version]
    query = create_params
    begin

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

    def nested_values?(value_to_check, result = [])
      result << true if value_to_check.class == String && value_to_check.present?

      if value_to_check.class == Array
        value_to_check.each do |value|
Severity: Minor
Found in app/controllers/surveys_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 nested_values? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def nested_values?(value_to_check, result = [])
      result << true if value_to_check.class == String && value_to_check.present?

      if value_to_check.class == Array
        value_to_check.each do |value|
Severity: Minor
Found in app/controllers/application_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 visibility_location_href has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def visibility_location_href(item, item_class)
    return "location.href = '/visibility/#{item_class}/#{item.id}/#{item.visible ? 'false' : 'true'}/#{item.survey_poll_id}';" if item_class === "Survey_Comment"

    "location.href = '/visibility/#{item_class}/#{item.id}/#{item.visible ? 'false' : 'true'}';"
  end
Severity: Minor
Found in app/helpers/application_helper.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

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

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

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

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

    def new_tour
Severity: Minor
Found in app/controllers/tours_controller.rb by reek

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

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

  def format_birth_date(birth_date)

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

User#minio is a writable attribute
Open

                :authentication_token, :roles, :permission, :minio
Severity: Minor
Found in app/models/user.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

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

    def visibility_redirect_to(params)

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

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

    def new_static_content_record(params = nil)

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

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

  def to_local_date_time(date_time)
Severity: Minor
Found in app/helpers/application_helper.rb by reek

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

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

  def i18n_json_to_text(json)
Severity: Minor
Found in app/helpers/i18n_helper.rb by reek

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

User#applications is a writable attribute
Open

  attr_accessor :name, :email, :data_provider, :data_provider_id, :applications,
Severity: Minor
Found in app/models/user.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

User#roles is a writable attribute
Open

                :authentication_token, :roles, :permission, :minio
Severity: Minor
Found in app/models/user.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

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

    def new_generic_item

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

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

  def empty?(object, fields)
Severity: Minor
Found in app/helpers/form_helper.rb by reek

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

Severity
Category
Status
Source
Language