publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Method revisions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def revisions
    @node = Node.find_wiki(params[:id])
    if @node
      @revisions = @node.revisions
      @pagy_revisions, @revisions = pagy(@revisions.where(status: 1), items: 20) unless current_user&.can_moderate?
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

    elsif tagname == 'blog' && user.basic_user?
      errors ? 'Only moderators or admins can use this tag.' : false
    elsif tagname.split(':')[0] == 'redirect' && Node.where(slug: one_split).size <= 0
      errors ? I18n.t('node.page_does_not_exist') : false
    elsif socials[one_split&.to_sym].present?
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Method smtp_test has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def smtp_test
    require 'socket'

    s = TCPSocket.new ActionMailer::Base.smtp_settings[:address], ActionMailer::Base.smtp_settings[:port]

Severity: Minor
Found in app/controllers/admin_controller.rb - About 45 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 useremail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def useremail 
   if logged_in_as(['admin', 'moderator']) 
     if params[:address] 
       # address was submitted. find the username(s) and return. 
       @address = params[:address] 
Severity: Minor
Found in app/controllers/admin_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

          if Random.rand(2) == 0
            redirect_to Node.find(@node.power_tag('abtest')).path
            return
          end
Severity: Major
Found in app/controllers/wiki_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        elsif current_user.can_moderate?
          flash.now[:warning] = "Only moderators and admins see this page, as it is redirected to #{Node.find(@node.power_tag('abtest')).title} roughly around 50% of the time.
        To remove this behavior, delete the tag beginning with 'abtest:'"
Severity: Major
Found in app/controllers/wiki_controller.rb - About 45 mins to fix

Method rich has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def rich
    if params[:main_image] && Image.find_by(id: params[:main_image])
      @main_image = Image.find_by(id: params[:main_image]).path
    end

Severity: Minor
Found in app/controllers/editor_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

      errors ? I18n.t('node.only_admins_can_lock') : false
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              rescue StandardError
                return [false, tag.destroy]
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              unless tag.subscriptions.empty? || isStatusValid || !isMonthOld
                SubscriptionMailer.notify_tag_added(self, tag, user).deliver_later
              end
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Method add_comment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def add_comment(params = {})
    thread = !comments.empty? && !comments.last.nil? && !comments.last.thread.nil? ? comments.last.next_thread : '01/'
    comment_via_status = params[:comment_via].nil? ? 0 : params[:comment_via].to_i
    user = User.find(params[:uid])
    status = user.first_time_poster && user.first_time_commenter ? 4 : 1
Severity: Minor
Found in app/models/node.rb - About 45 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

Avoid deeply nested control flow statements.
Open

              unless params[:hash_params].to_s.empty?
                hash_params = URI.parse("#" + params[:hash_params]).to_s
              end
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Method tagNearbyNodes has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, sort_by = nil, order_direction = nil, limit = 10)
Severity: Minor
Found in app/services/search_service.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if oidreq.immediate
                oidresp = oidreq.answer(false)
              elsif session[:username]
                # The user hasn't logged in.
                # show_decision_page(oidreq) # this doesnt make sense... it was in the example though
Severity: Major
Found in app/controllers/openid_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if session[:openid_return_to] # for openid login, redirects back to openid auth process
              return_to = session[:openid_return_to]
              session[:openid_return_to] = nil
              redirect_to return_to + hash_params
            elsif params[:return_to] && params[:return_to].split('/')[0..3] == ["", "subscribe", "multiple", "tag"]
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Method decision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def decision
    oidreq = session[:last_oidreq]
    session[:last_oidreq] = nil
    id_to_send = params[:id_to_send]
    identity = oidreq&.identity
Severity: Minor
Found in app/controllers/openid_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

            if session[:openid_return_to] # for openid login, redirects back to openid auth process
              return_to = session[:openid_return_to]
              session[:openid_return_to] = nil
              redirect_to return_to + hash_params
            else
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            params[:user_session][:openid_identifier] = 'https://old.publiclab.org/people/' + username + '/identity' if username
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                tagnames = params[:tagnames].class == Array ? params[:tagnames].join(', ') : params[:tagnames]
Severity: Major
Found in app/controllers/subscription_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            render json: { status: status, message: message, id: tag.tid, tagname: params[:name], url: "/tags" + "?_=" + Time.now.to_i.to_s } if current_user
Severity: Major
Found in app/controllers/subscription_controller.rb - About 45 mins to fix
Severity
Category
Status
Source
Language