fiedl/your_platform

View on GitHub

Showing 251 of 251 total issues

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

  def fill_cache
    super
    parent.fill_cache if parent && parent.children.first.id == self.id
    if !parent && profileable && profileable.respond_to?(:renew_cache)
      self.class.cached_profileable_methods_depending_on_profile_fields.each do |method|
Severity: Minor
Found in app/models/concerns/profile_field_caching.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 confirm_admins_only_access_if_needed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def confirm_admins_only_access_if_needed
    if request.get? and request.format.html?
      if current_navable and can?(:read, current_navable) and not current_ability_as_user.can?(:read, current_navable)
        confirm_admins_only_access
      end
Severity: Minor
Found in app/controllers/concerns/confirm_admins_only_access.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 groups_of_user_table has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def groups_of_user_table(user, options = {require_post_ability: false})
    content_tag :table, :class => "user_groups" do
      content_tag :tr do

        # first column:
Severity: Minor
Found in app/helpers/groups_helper.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 group_tree has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def group_tree(group, options = {class: "tree"}, &block)
    content_tag :ul, class: options[:class] do
      group.child_groups.collect do |child_group|
        content_tag :li do
          (block_given? ? yield(child_group) : child_group.name).html_safe +
Severity: Minor
Found in app/helpers/groups_helper.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 editable has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def editable(object, key, type: 'text', editable: nil, placeholder: nil, class: nil, input_class: nil, link_to: nil)
    if type == 'date'
      initial_value = localize object.send(key).to_date if object.send(key)
    elsif type == 'datetime'
      initial_value = localize object.send(key) if object.send(key)
Severity: Minor
Found in app/helpers/editable_helper.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 resource_breadcrumbs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def resource_breadcrumbs
    ancestor_resource_controllers.reverse.collect { |controller|
      if controller
        if controller.action_methods.include? 'index'
          underscored_controller_name = controller.name.gsub("Controller", "").underscore
Severity: Minor
Found in app/helpers/breadcrumbs_helper.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 fetch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def fetch(key, options = {}, &block)
    # We need to have this in local memory. Otherwise, the value might change until
    # we compare the timestamps.
    r = renew_at

Severity: Minor
Found in core_ext/active_support/cache.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 lucky_guess has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def lucky_guess
    query_string = params[:query]
    if query_string.present?
      @result = Event.where(name: query_string).limit(1).first
      @result ||= Page.where(title: query_string).limit(1).first
Severity: Minor
Found in app/controllers/search_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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @user_params = user_params
    @basic_user_params = @user_params.select { |key, value| key.to_s.in? ['first_name', 'last_name', 'email', 'female', 'create_account'] }
    @basic_user_params[:first_name] ||= I18n.t(:first_name)
    @basic_user_params[:last_name] ||= I18n.t(:last_name)
Severity: Minor
Found in app/controllers/users_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

concern :GroupHeraldicsWappen do
  included do
    has_many :wappen_attachments, -> { where(title: 'wappen') }, class_name: "Attachment", as: :parent
  end

Severity: Major
Found in app/models/concerns/group_heraldics.rb and 1 other location - About 1 hr to fix
app/models/concerns/group_heraldics.rb on lines 41..68

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

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

concern :GroupHeraldicsZirkel do
  included do
    has_many :zirkel_attachments, -> { where(title: 'zirkel') }, class_name: "Attachment", as: :parent
  end

Severity: Major
Found in app/models/concerns/group_heraldics.rb and 1 other location - About 1 hr to fix
app/models/concerns/group_heraldics.rb on lines 10..37

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

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

Function handler has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handler = fragment => {
    const nodes = [];

    fragment.forEach(child => {
      if (child.isText) {
Severity: Minor
Found in app/vue/lib/tiptap/node_paste_rule.js - About 1 hr to fix

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

      def change
        create_table :decision_making_processes do |t|
          t.string :title
          t.string :type
          t.text :wording
    demo_app/my_platform/db/migrate/20170119131524_create_term_report_member_entries.your_platform.rb on lines 3..21

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

    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

      def change
        create_table :term_report_member_entries do |t|
          t.integer :user_id
          t.integer :term_report_id
    
    
    demo_app/my_platform/db/migrate/20170626143906_create_decision_making_processes.your_platform.rb on lines 3..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 48.

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

      def unassociate_profileable_and_renew_profileable_cache
        if not parent
          former_profileable = profileable
          self.profileable = nil if self.profileable_id
          self.save
    Severity: Minor
    Found in app/models/concerns/profile_field_caching.rb - About 55 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 content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def content
        if @email.multipart?
          if @email.html_part
            @content_type = 'html'
            normalize_body(@email.html_part, @email.html_part.charset)
    Severity: Minor
    Found in app/models/received_mail.rb - About 55 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 deliver has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def deliver
        if not user.has_account?
          self.comment = "User has no account."
          self.failed_at = Time.zone.now
          self.save
    Severity: Minor
    Found in app/models/post_delivery.rb - About 55 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_special_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_special_group( group_flag, options = {} )
          object_to_search = options[:parent_element].try(:child_groups)
          object_to_search ||= Group unless options[:local]
          object_to_search.find_by_flag( group_flag.to_sym ) if object_to_search && object_to_search != []
        end
    Severity: Minor
    Found in app/models/concerns/special_groups.rb - About 55 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 age has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def age
        now = Time.now.utc.to_date
        dob = self.date_of_birth
        if dob
          now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
    Severity: Minor
    Found in app/models/concerns/user_date_of_birth.rb - About 55 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 member_of? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def member_of?( object, options = {} )
        if object.kind_of? Group
          if options[:at]
            Membership.find_all_by(user: self, group: object).at_time(options[:at]).any?
          elsif options[:with_invalid] or options[:also_in_the_past]
    Severity: Minor
    Found in app/models/concerns/user_roles.rb - About 55 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