berkmancenter/lumendatabase

View on GitHub

Showing 47 of 47 total issues

Function keydown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

, keydown: function (e) {
var $this
, $items
, $active
, $parent
Severity: Minor
Found in app/assets/javascripts/lumen/bootstrap-dropdown.js - About 1 hr to fix

    Method approve_request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def approve_request
    new_entity = Entity.create!(
    name: self.entity_name,
    kind: self.entity_kind,
    address_line_1: self.entity_address_line_1,
    Severity: Minor
    Found in app/models/api_submitter_request.rb - About 1 hr to fix

      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

      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

      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

      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

      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

      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

      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

      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

      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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      { from: now - 1.day, to: now },
      { from: now - 1.month, to: now },
      { from: now - 6.months, to: now },
      { from: now - 12.months, to: now },
      Severity: Minor
      Found in app/models/elasticsearch/date_range_filter.rb and 1 other location - About 30 mins to fix
      app/models/media_mention.rb on lines 18..21

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      { from: now - 1.year, to: now },
      { from: now - 5.years, to: now },
      { from: now - 10.years, to: now },
      { from: now - 20.years, to: now }
      Severity: Minor
      Found in app/models/media_mention.rb and 1 other location - About 30 mins to fix
      app/models/elasticsearch/date_range_filter.rb on lines 47..50

      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
          Severity: Major
          Found in lib/yt_importer/yt_importer.rb - About 30 mins to fix

            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: 'Use a valid email address.'
              }
              Severity: Major
              Found in app/controllers/token_urls_controller.rb - About 30 mins to fix

                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

                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
                Severity
                Category
                Status
                Source
                Language