thedrummeraki/tanoshimu

View on GitHub

Showing 66 of 66 total issues

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

  def fetch_arg_from_args(job, klass, type)
    job.arguments.each do |arg|
      return arg if arg.is_a?(klass)

      if arg.is_a?(Hash)
Severity: Minor
Found in app/jobs/trackable_job.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def perform
        show = Show.find_kitsu(kitsu_id)
        show = if show.present?
          needs_update?(show) ? update_show_from_kitsu!(show) : show
        else
Severity: Minor
Found in app/operations/shows/kitsu/get.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def perform
        return if show.blank?
        return unless anilist_id.present?

        return if show.air_complete?
Severity: Minor
Found in app/operations/shows/anilist/next_airing_episode.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 find_user_from_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def find_user_from_token(token)
    Rails.logger.info("Fetching token info...")
    response = RestClient.get(
      "https://id.youranime.moe/me.json",
      { 'Authorization' => "Bearer #{token}" }
Severity: Minor
Found in app/helpers/bearer_token_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

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

  def prepare_variables(variables_param)
    case variables_param
    when String
      if variables_param.present?
        JSON.parse(variables_param) || {}
Severity: Minor
Found in app/controllers/graphql_controller.rb and 1 other location - About 35 mins to fix
app/controllers/admin/graphql_controller.rb on lines 38..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def create_shows_then_next_page(season)
      Rails.logger.info("[Shows::Sync] #{request_airing_url(season)}")
      there_is_data = true
      created_shows = []

Severity: Minor
Found in app/operations/shows/sync.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 current_next_airing_info.up_to_date!
Severity: Major
Found in app/operations/shows/anilist/next_airing_episode.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return sync_shows if sync_type == :shows
    Severity: Major
    Found in app/operations/shows/sync.rb - About 30 mins to fix

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

          def initialize(tag, ascending: nil)
            self.class.ensure_tag!(tag)
      
            @tag = tag.to_sym
            @use_scope = ACCEPTED_FILTERS.dig(@tag, :use_scope)
      Severity: Minor
      Found in app/models/shows/filter.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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def show
            slug_or_id = params[:show_id] || params[:id]
            if (@show = Show.find_by_slug(slug_or_id) || Show.find_by(id: slug_or_id))
              Shows::Kitsu::Get.perform(kitsu_id: @show.reference_id, force_update: true) if @show.kitsu?
              render('show')
      Severity: Minor
      Found in app/controllers/admin/shows_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 provider_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def provider_info(provider)
            info = PROVIDERS_MAP[provider.to_s]
            oauth_class = info && info[:class]
            oauth_class = oauth_class.constantize unless oauth_class.is_a?(Class)
            raise "Invalid OAuth provider: #{provider}" if oauth_class.nil?
      Severity: Minor
      Found in app/models/concerns/oauth_concern.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 categories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.categories(context:, filters: {}, include_others: false)
                categories_classes = include_others ? all_categories_classes : main_categories_classes
      
                categories_classes.map do |category_class|
                  category = category_class.new(context: context, filters: filters)
      Severity: Minor
      Found in app/models/home/categories/providers/default.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 name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def name(format: DEFAULT_FORMAT)
          return unless valid?
      
          properties = format.scan(FORMAT_RE).flatten
      
      
      Severity: Minor
      Found in app/models/actor.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 streaming_platforms_from_anilist! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def streaming_platforms_from_anilist!(show)
            anilist_id = show.anilist_id
            return unless anilist_id.present?
      
            show_urls = Shows::Anilist::Streamers.perform(
      Severity: Minor
      Found in app/operations/kitsu/application_operation.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 badge_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def badge_options
          options = {}
      
          if show_type == 'movie'
            options.merge!({ type: :info, text: t('anime.shows.movie') })
      Severity: Minor
      Found in app/components/show_thumbnail_component.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def execute
          variables = prepare_variables(params[:variables])
          query = params[:query]
          operation_name = params[:operationName]
      
      
      Severity: Minor
      Found in app/controllers/graphql_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

      Function getResults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function getResults() {
          $.ajax({
              url: "/api/get/shows",
              method: 'post',
              data: 'token='+ token + '&get_host=true',
      Severity: Minor
      Found in public/js/tags-mgmt.js - 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def execute
          variables = prepare_variables(params[:variables])
          query = params[:query]
          operation_name = params[:operationName]
      
      
      Severity: Minor
      Found in app/controllers/admin/graphql_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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            printf('Generating for shows: ')
            @successful_ids = []
            shows.each do |show|
              result = show.update_banner_and_poster_urls!(force: force)
      Severity: Minor
      Found in app/operations/show/generate_urls.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 airing_in has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def airing_in(starts_on)
          difference = (starts_on - current_time.to_date).to_i
          difference_this_week = difference.abs % 7
          return { title: 'time.airing.today.title', content: 'time.airing.today.content' } if difference_this_week == 0
      
      
      Severity: Minor
      Found in app/helpers/application_helper.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