berkmancenter/lumendatabase

View on GitHub

Showing 36 of 47 total issues

Method validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def validate
    if @notice.nil?
      return {
        status: false,
        why: 'Notice not found.'
Severity: Minor
Found in app/controllers/token_urls_controller.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 included has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.included(model)
    model.instance_eval do
      to_validate = self.columns.select do |col|
        %i[string text].include?(col.type)
      end
Severity: Minor
Found in lib/validates_automatically.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 good_urls? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def good_urls?
    %i[url url_original].each do |attr|
      # URI::regexp will fail for things like "//bar.com", but we want to
      # allow those.
      value = self.send(attr)
Severity: Minor
Found in lib/validates_urls.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    unless authorized_to_create?
      Rails.logger.warn "Could not auth user with params: #{params}"
      redirect_to_new_form({
        type: 'alert',
Severity: Minor
Found in app/controllers/submitter_widget_notices_controller.rb - About 35 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 new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    # Iframe session won't be kept so we need to use GET params
    flash.now[params[:flash_message]['type']] = params[:flash_message]['message'] if params[:flash_message]

    @display_models = Notice.display_models - [DataProtection]
Severity: Minor
Found in app/controllers/submitter_widget_notices_controller.rb - About 35 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_all_entities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def set_all_entities
    return unless !!user && !!(entity = user.entity)

    set_entity(:submitter, entity) unless entity_present?(:submitter)
    set_entity(:recipient, entity) unless entity_present?(:recipient)
Severity: Minor
Found in app/models/notice_builder.rb - About 35 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 get_notice_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def get_notice_type(params)
    type_string = params[:type] || params[:notice][:type] || 'DMCA'
    type_string = 'DMCA' if type_string == 'Dmca'

    notice_type = type_string.classify.constantize
Severity: Minor
Found in app/controllers/notices_controller.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    redirect_to root_path and return if params[:destination].nil?

    if params.dig('g-recaptcha-response-data', 'gateway')
      success_captcha = verify_recaptcha(action: 'gateway', minimum_score: 0.5)
Severity: Minor
Found in app/controllers/captcha_gateway_controller.rb - About 35 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @new_token_params = token_url_params

    clean_up_email_address

Severity: Minor
Found in app/controllers/token_urls_controller.rb - About 35 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 too many return statements within this method.
Open

      return {
        status: false,
        why: 'This IP address is not allowed. Try to use a different ' \
             'IP address.'
      }
Severity: Major
Found in app/controllers/token_urls_controller.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return {
            status: false,
            why: 'This email address is not allowed. Try to use a different ' \
                 'email address.'
          }
    Severity: Major
    Found in app/controllers/token_urls_controller.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return {
              status: false,
              why: 'This email address has been used already. Use a different ' \
                   'email, wait until the previous url expires or contact our ' \
                   'team at team@lumendatabase.org to get a researcher account.'
      Severity: Major
      Found in app/controllers/token_urls_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return {
                status: false,
                why: 'Use a valid email address.'
              }
        Severity: Major
        Found in app/controllers/token_urls_controller.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return
          Severity: Major
          Found in lib/yt_importer/yt_importer.rb - About 30 mins to fix

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

                  def parse_works
                    infringing_urls = parsed_infringing_urls.map do |url|
                      uri = URI.parse(url)
                      valid = %w(http https).include?(uri.scheme)
                      unless valid
            Severity: Minor
            Found in lib/yt_importer/mapping/base.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 default_kind_based_on_role has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def default_kind_based_on_role(role)
                if role == 'issuing_court' ||
                   (role == 'principal' && @notice.class == LawEnforcementRequest) ||
                   (role == 'principal' && @notice.class == GovernmentRequest)
                  'organization'
            Severity: Minor
            Found in app/controllers/submitter_widget_notices_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