mishina2228/youtube-api-trial

View on GitHub

Showing 5 of 23 total issues

Method search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def search
      ret = ::Channel.preload(:tags)
      ret = ret.where(id: ids) if ids.present?
      ret = ret.where("title LIKE ? ESCAPE '\\'", "%#{::Channel.sanitize_sql_like(title)}%") if title.present?
      ret = ret.where(published_at: published_at) if published_at.present?
Severity: Minor
Found in app/models/search/channel.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

Function prepEditChannelTag has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const prepEditChannelTag = btn => {
  btn.addEventListener('click', e => {
    e.preventDefault()
    const form = e.currentTarget.parentNode
    Shared.sendAction(form, 'text/html')
Severity: Minor
Found in app/javascript/controllers/channel_tag.js - About 1 hr to fix

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

      def sortable(title, order, html_options = {})
        direction = sort_column == order && sort_direction == 'desc' ? 'asc' : 'desc'
        if sort_column == order
          title += direction == 'asc' ? '▼' : '▲'
        end
    Severity: Minor
    Found in app/helpers/application_helper.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 before_enqueue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.before_enqueue(params = {})
          jobs = JobUtils.peek(@queue, 0, 100)
          jobs.each do |job|
            next if job['class'] != name
    
    
    Severity: Minor
    Found in app/jobs/channels/update_snippet_job.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 before_enqueue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.before_enqueue(params = {})
          jobs = JobUtils.peek(@queue, 0, 100)
          jobs.each do |job|
            next if job['class'] != name
    
    
    Severity: Minor
    Found in app/jobs/channels/build_statistics_job.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