Noosfero/noosfero

View on GitHub

Showing 1,031 of 1,643 total issues

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

    def define_target(validation)
      if validation == :region
        if params[:create_enterprise] && params[:create_enterprise][:target_id]
          Profile.find(params[:create_enterprise][:target_id])
        end
Severity: Minor
Found in app/controllers/public/enterprise_registration_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 filter_in_a_georef_circle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.filter_in_a_georef_circle(params)
    unless params[:lat].blank? && params[:lng].blank?
      lat, lng = [params[:lat].to_f, params[:lng].to_f]
    end
    if !lat
Severity: Minor
Found in app/models/profile.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 limit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def limit
      if map_search?(@searches)
        MAP_SEARCH_LIMIT
      elsif !multiple_search?
        if [:people, :communities, :enterprises].include? @asset
Severity: Minor
Found in app/controllers/public/search_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 upload_quota_sizes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def upload_quota_sizes
      quotas = metadata["quotas"] || {}
      quotas.each do |klass, quota|
        float_quota = Float(quota) rescue nil
        if quota.present? && float_quota.nil?
Severity: Minor
Found in app/models/environment.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_profile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_profile(profile)
    return if profiles.include?(profile)

    if moderated
      tasks = environment.tasks.pending.where(type: "ApproveKind").where(requestor: profile)
Severity: Minor
Found in app/models/kind.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 insert_boxes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def insert_boxes(content)
    if controller.send(:boxes_editor?) && controller.send(:uses_design_blocks?)
      content + display_boxes_editor(controller.boxes_holder)
    else
      maybe_display_custom_element(controller.boxes_holder, :custom_header_expanded, id: "profile-header") +
Severity: Minor
Found in app/helpers/boxes_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 profile_suggestion_tag_connections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def profile_suggestion_tag_connections(suggestion)
    tags = suggestion.tag_connections.first(4).map do |tag|
      tag.name + ", "
    end
    last_tag = tags.pop
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

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

  def index
    @offsets = { wall: 0, network: 0 }
    page = (params[:page] || 1).to_i
    if logged_in?
      @activities = loop_fetch_activities(@profile.activities, :wall, page) if @profile.display_to?(user, :wall)
Severity: Minor
Found in app/controllers/public/profile_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 current_editor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def current_editor(mode = "")
    editor = @article.editor || Article::Editor::TINY_MCE unless @article.nil?
    editor ||= (current_person.nil? || current_person.editor.nil?) ? Article::Editor::TINY_MCE : current_person.editor
    editor += "_" + mode unless mode.blank?
    editor
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

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

  def suggestion_based_on_username(requested_username = "")
    return "" if requested_username.empty?

    requested_username = requested_username.downcase.tr("^#{Profile::IDENTIFIER_FORMAT}", "")
    usernames = []
Severity: Minor
Found in app/helpers/account_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 send_mail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def send_mail
    @mailing = profile.mailings.build(params[:mailing])
    @mailing.data = session[:members_filtered] ? { members_filtered: session[:members_filtered] } : {}
    @email_templates = profile.email_templates.where template_type: :organization_members
    if request.post?
Severity: Minor
Found in app/controllers/public/profile_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 set_portal_folders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def set_portal_folders
    @selected = (environment.portal_folders || [])
    @available_portal_folders = environment.portal_community.folders - @selected

    if request.post?
Severity: Minor
Found in app/controllers/admin/admin_panel_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 article_list_to_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def article_list_to_json(list)
      list.map do |item|
        {
          "title" => item.title,
          "url" => item.image? ? item.public_filename(:uploaded) : url_for(item.url),
Severity: Minor
Found in app/controllers/my_profile/cms_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 invite_event_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def invite_event_to(article)
      profiles = profile.kind_of?(Organization) ? profile.members : profile.friends
      inviteds = article.invitations if article.event?
      result = []
      profiles.each do |profile|
Severity: Minor
Found in app/controllers/my_profile/cms_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 start_thread has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def start_thread
          @mutex.synchronize do
            return if @thread && @thread.alive?

            @thread = Thread.new do
Severity: Minor
Found in lib/noosfero/scheduler/defer.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 activate_enterprise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def activate_enterprise
    @terms_of_use = environment.terms_of_use
    @enterprise = load_enterprise
    @question = @enterprise.question
    return unless check_answer
Severity: Minor
Found in app/controllers/public/account_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 update_profile_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def update_profile_data
      @profile_data = profile
      if request.post?
        begin
          @profile_data.update!(params[:profile_data])
Severity: Minor
Found in app/controllers/my_profile/profile_editor_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 period has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def period(from_date, until_date)
      return nil if from_date.nil? && until_date.nil?

      begin_period = from_date.nil? ? Time.at(0).to_datetime : from_date
      end_period = until_date.nil? ? DateTime.now : until_date
Severity: Minor
Found in app/api/helpers.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 NOOSFERO_CONF has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.NOOSFERO_CONF
      if @@NOOSFERO_CONF
        @@NOOSFERO_CONF
      else
        file = Rails.root.join("config", "noosfero.yml")
Severity: Minor
Found in app/api/app.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 load_recent_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def load_recent_files(parent_id = nil, q = nil, paginate_options = { page: 1, per_page: 6 })
      # TODO Since we only have special support for images, I'm limiting myself to
      #     consider generic files as non-images. In the future, with more supported
      #     file types we'll need to have a smart way to fetch from the database
      #     scopes of each supported type as well as the non-supported types as a
Severity: Minor
Found in app/controllers/my_profile/cms_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

Severity
Category
Status
Source
Language