zealot128/podfilter.de

View on GitHub

Showing 16 of 16 total issues

Method update_sources has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def update_sources(opml_file)
    document = Nokogiri::XML.parse(opml_file.source)
    outlines = document.search('outline')
    if outlines.count ==0
      @log << t('no_entries_found')
Severity: Minor
Found in app/services/opml_import.rb - About 2 hrs 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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      sources.each do |source|
        doc = nil
        begin
          doc = Nokogiri::XML.parse(open(source.url))
Severity: Minor
Found in app/services/auto_import.rb - About 2 hrs 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 validate_each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
    value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
    return if value.length == 0

Severity: Minor
Found in lib/file_mime_type_validator.rb - About 1 hr 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 check_validity! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def check_validity!
    keys = CHECKS & options.keys

    if keys.empty?
      raise ArgumentError, 'Patterns unspecified. Specify the :content_type option.'
Severity: Minor
Found in lib/file_mime_type_validator.rb - About 1 hr 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 merge_urls_to_podcast has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def merge_urls_to_podcast(urls)
    sources = []
    missing = []
    main = nil
    urls.each do |url|
Severity: Minor
Found in app/services/auto_import.rb - About 1 hr to fix

    Method by_episode_title has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.by_episode_title(limit: 50, modus: :auto)
        all = Episode.joins(:source).group('episodes.title').where('length(title) > 12').having('count(distinct podcast_id) > 1').pluck('title, array_agg(distinct podcast_id)').map{|title, podcast_ids| [title, podcast_ids.sort ]}.select{|t,_| t.present? and t.length > 11 }
        descending = all.group_by{|t,p| p}.map{|p, ps| [p, ps.count]}.select{|p,c| c >= limit }.sort_by{|p,c| -c}
    
        j = 0
    Severity: Minor
    Found in app/services/duplicate_finder.rb - About 1 hr to fix

      Method update_podcast_meta_information has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_podcast_meta_information(podcast)
          podcast.title ||= parsed_feed.title if parsed_feed.title
          podcast.description ||= take_first(parsed_feed, [:itunes_summary, :description, :title]).strip rescue nil
          text = ActionController::Base.new.view_context.strip_tags [ parsed_feed.entries.map(&:summary), podcast.description, podcast.title].join('. ')
          podcast.language = text.language
      Severity: Minor
      Found in app/services/feed_fetcher.rb - About 1 hr 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_entries has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_entries
          parsed_feed.entries.each do |entry|
            guid = entry.respond_to?(:entry_id) ? entry.entry_id : entry.guid
            if guid.blank?
              guid = entry.published && entry.published.to_s
      Severity: Minor
      Found in app/services/feed_fetcher.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 by_episode_title has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.by_episode_title(limit: 50, modus: :auto)
          all = Episode.joins(:source).group('episodes.title').where('length(title) > 12').having('count(distinct podcast_id) > 1').pluck('title, array_agg(distinct podcast_id)').map{|title, podcast_ids| [title, podcast_ids.sort ]}.select{|t,_| t.present? and t.length > 11 }
          descending = all.group_by{|t,p| p}.map{|p, ps| [p, ps.count]}.select{|p,c| c >= limit }.sort_by{|p,c| -c}
      
          j = 0
      Severity: Minor
      Found in app/services/duplicate_finder.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 merge_urls_to_podcast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def merge_urls_to_podcast(urls)
          sources = []
          missing = []
          main = nil
          urls.each do |url|
      Severity: Minor
      Found in app/services/auto_import.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 do_validation has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def do_validation(value, pattern, key, record, attribute)
      Severity: Minor
      Found in lib/file_mime_type_validator.rb - About 35 mins to fix

        Method current_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def current_user(create=false)
            owner = if params[:token]
              Owner.where(token: params[:token]).first
            elsif session[:owner_id]
              Owner.find(session[:owner_id])
        Severity: Minor
        Found in app/controllers/application_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 check_redirect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_redirect
            if source.url != parsed_feed.feed_url
              parent = Source.where(url: parsed_feed.feed_url).first_or_initialize
              parent.podcast ||= source.podcast
              parent.save
        Severity: Minor
        Found in app/services/feed_fetcher.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 do_validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def do_validation(value, pattern, key, record, attribute)
            return if value.file.content_type.send((pattern.is_a?(String) ? "==" : "=~" ), pattern)
        
            errors_options = options.except(*RESERVED_OPTIONS)
        
        
        Severity: Minor
        Found in lib/file_mime_type_validator.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(user)
            can [:show], OpmlFile
            can [:index, :show], Source
        
            if user && user.opml_files.count > 0
        Severity: Minor
        Found in app/models/ability.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 badges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def badges
            b = []
            if active? and !offline?
              b << :active
            elsif active == false and !offline?
        Severity: Minor
        Found in app/models/source.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