datacite/volpino

View on GitHub

Showing 45 of 65 total issues

Avoid too many return statements within this method.
Open

    return OpenStruct.new(body: { "errors" => work.validation_errors.map { |error| { "title" => error } } }) if work.validation_errors.present?
Severity: Major
Found in app/models/claim.rb - About 30 mins to fix

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

        def load_index
          authorize! :manage, Phrase
    
          sort = case params[:sort]
                 when "relevance" then { "_score" => { order: "desc" } }
    Severity: Minor
    Found in app/controllers/admin/users_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 encode_cookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def encode_cookie(jwt)
          expires_in = 30 * 24 * 3600
          expires_at = Time.now.to_i + expires_in
          value = '{"authenticated":{"authenticator":"authenticator:oauth2","access_token":"' + jwt + '","expires_in":' + expires_in.to_s + ',"expires_at":' + expires_at.to_s + "}}"
    
    
    Severity: Minor
    Found in app/models/concerns/authenticable.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 empty_cookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def empty_cookie
        value = '{"authenticated":{}}'
    
        domain = if Rails.env.production?
          ".datacite.org"
    Severity: Minor
    Found in app/controllers/users/sessions_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 format_error_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def format_error_message(messages)
        Array.wrap(messages) do |msg|
          if msg["title"].is_a?(Hash) && msg.dig("title", "developer-message").present?
            title = msg.dig("title", "developer-message")
          elsif msg["title"].is_a?(String)
    Severity: Minor
    Found in app/models/claim.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