Noosfero/noosfero

View on GitHub

Showing 1,031 of 1,643 total issues

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

  def events_source
    return environment if all_env_events

    if self.owner.kind_of? Environment
      environment.portal_community ? environment.portal_community : environment
Severity: Minor
Found in plugins/event/lib/event_plugin/event_block.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 filter_bool has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def filter_bool(options = {})
      environment = options[:environment].presence
      user = options[:user].presence

      result_filter = {}
Severity: Minor
Found in plugins/elasticsearch/lib/searchable_model/filter.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 queries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def queries
    @order_options = [
      [_("Older"), "older"],
      [_("Recent"), "recent"]
    ]

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

    def period_range(form)
      if form.beginning.blank? && form.ending.blank?
        _("Always")
      elsif form.beginning.present? && form.ending.blank?
        ("From %s") % time_format(form.beginning)
Severity: Minor
Found in plugins/custom_forms/lib/custom_forms_plugin/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

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

    def validate_delivery_dates
      return if self.new? || delivery_start.nil? || delivery_finish.nil?

      errors.add :base, I18n.t("orders_cycle_plugin.models.cycle.invalid_delivery_peri") unless delivery_start < delivery_finish
      errors.add :base, I18n.t("orders_cycle_plugin.models.cycle.delivery_period_befor") unless finish <= delivery_start
Severity: Minor
Found in plugins/orders_cycle/models/orders_cycle_plugin/cycle.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 next_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def next_status(actor_name)
    # allow supplier to confirm and receive orders if admin is true
    actor_statuses = if actor_name == :supplier then Statuses else StatusesByActor[actor_name] end
    # if no status was found go to the first (-1 to 0)
    current_index = Statuses.index(self.status) || -1
Severity: Minor
Found in plugins/orders/models/orders_plugin/order.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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add
    product = find_product(params[:id])
    if product && (profile = validate_same_profile(product))
      self.cart = { profile_id: profile.id, items: {} } if self.cart.nil?
      self.cart[:items][product.id] = 0 if self.cart[:items][product.id].nil?
Severity: Minor
Found in plugins/shopping_cart/controllers/shopping_cart_plugin_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 family_relation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def family_relation(_profile)
      @communities = _profile.communities
      @enterprises = _profile.enterprises
      @full = true

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

  def article_extra_contents(article)
    proc do
      settings = Noosfero::Plugin::Settings.new(environment, SocialSharePrivacyPlugin)
      modules = settings.networks.map { |service| "/plugins/social_share_privacy/socialshareprivacy/javascripts/modules/#{service}.js" }
      locale = FastGettext.locale
Severity: Minor
Found in plugins/social_share_privacy/lib/social_share_privacy_plugin.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 holder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def holder
    return nil if self.box.nil? || self.box.owner.nil?

    if self.box.owner.kind_of?(Environment)
      return nil if self.box.owner.portal_community.nil?
Severity: Minor
Found in plugins/recent_content/lib/recent_content_block.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 login_from_cookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def login_from_cookie
      return if cookies[:auth_token].blank? || logged_in?

      token = cookies[:auth_token].to_s.match(/auth_token=(.*);/)
      token = token ? token[1] : nil
Severity: Minor
Found in app/concerns/authenticated_system.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 posts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def posts(data = {})
    limit = self.posts_per_blog.zero? ? nil : self.posts_per_blog
    posts = if self.last_send_at.nil?
              self.blogs.flat_map do |blog|
                blog.posts
Severity: Minor
Found in plugins/newsletter/lib/newsletter_plugin/newsletter.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 current_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.current_user(request, environment)
    remote_user = request.env["HTTP_REMOTE_USER"]
    user_data = request.env["HTTP_REMOTE_USER_DATA"]

    remote_user_email = user_data.blank? ? (remote_user + "@remote.user") : JSON.parse(user_data)["email"]
Severity: Minor
Found in plugins/remote_user/lib/remote_user_plugin.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 publish_stories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def publish_stories(object_data, actor, stories)
    stories.each do |story|
      begin
        self.publish_story object_data, actor, story
      rescue => e
Severity: Minor
Found in plugins/open_graph/lib/open_graph_plugin/publisher.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 application_controller_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def application_controller_filters
    me = self
    {
      type: "before_action",
      method_name: "public_access_restriction",

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

    def attribute_option_name(name, klass, params)
      return nil if name.blank?

      if params[:attribute].to_s == "content_type"
        Noosfero::FriendlyMIME.find(name)[1..-1].upcase
Severity: Minor
Found in plugins/pg_search/lib/pg_search_plugin.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 profile_editor_controller_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def profile_editor_controller_filters
    block = proc do
      if request.post?
        if !params[:profile_data][:usp_id].blank? && !StoaPlugin::UspUser.matches?(params[:profile_data][:usp_id], params[:confirmation_field], params[params[:confirmation_field]])
          @profile_data = profile
Severity: Minor
Found in plugins/stoa/lib/stoa_plugin.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 build_answer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def build_answer(field, value, index)
      if field.is_a? CustomFormsPlugin::SelectField
        labels = value.split(";")
        ids = labels.map do |label|
          alternative = field.alternatives.find_by(label: label)
Severity: Minor
Found in plugins/custom_forms/lib/custom_forms_plugin/csv_handler.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 status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def status
    if beginning.try(:future?)
      :not_open
    elsif ending.try(:future?) && (ending < 3.days.from_now)
      :closing_soon
Severity: Minor
Found in plugins/custom_forms/lib/custom_forms_plugin/form.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 display_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def display_value(product)
      price = product.price
      return "" if price.blank? || price.zero?

      discount = product.discount
Severity: Minor
Found in plugins/products/lib/products_plugin/products_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

Severity
Category
Status
Source
Language