thedrummeraki/tanoshimu

View on GitHub

Showing 54 of 66 total issues

Function login has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function login(error_p_id, waiting_p_id, success_p_id, form_id, callback) {
    function edForm(form, readOnly) {
        if (form && form.elements) {
            var elements = form.elements;
            [].forEach.call(elements, function(e) {
Severity: Minor
Found in app/assets/javascripts/login.js - 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 compute_shows has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def compute_shows
        default_scope = self.class.default_scope
        if default_scope.is_a?(Array)
          Rails.logger.warn('Ignoring #scopes due to default scope being an array')
          return default_scope
Severity: Minor
Found in app/models/home/categories/base_category.rb - About 1 hr to fix

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

          def link_for(site, url)
            if site.downcase =~ /official site/
              method = persist ? :create! : :new
              ShowUrl.send(method, url_type: :official, value: url, show: show)
            else
    Severity: Minor
    Found in app/operations/shows/anilist/streamers.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 create_or_update_show_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_or_update_show_for(data, airing_status, show_obj: nil)
          fetched_attrs = data[:attributes]
          synched_show = show_obj.present? ? show_obj : find_show_from_attributes(fetched_attrs)
    
          if synched_show.persisted?
    Severity: Minor
    Found in app/operations/shows/sync.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 update_banner_and_poster_urls! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_banner_and_poster_urls!(**options)
        force = options[:force] || false
        return nil unless persisted?
        if !force
          return true if poster_url? && banner_url?
    Severity: Minor
    Found in app/models/show.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

    Avoid deeply nested control flow statements.
    Open

                if (episode.ratio !== undefined) {
                    var progressBar = $('div#progress_' + id);
                    ratioInfo = 'width: ' + parseInt(episode.ratio) + '%;';
                    progressBar.attr('style', ratioInfo);
                    progressBar.removeClass('hidden');
    Severity: Major
    Found in public/js/watched_episodes.js - About 45 mins to fix

      Method sync_show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def sync_show
            raise '`show` params is mandatory with sync_type: :show' unless show.present?
            return unless show.synchable?
      
            response = RestClient.get(request_show_url(show))
      Severity: Minor
      Found in app/operations/shows/sync.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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def perform
                Show.published.each do |show|
                  next unless show.synchable? && show.reference_source == 'kitsu'
      
                  Shows::Kitsu::Get.perform(
      Severity: Minor
      Found in app/operations/shows/kitsu/sync/update_existing.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

      Function goToNextId has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function goToNextId(currentId) {
          console.log("Going to the next episode if any...");
          $.ajax({
              type: 'get',
              url: '/json/get/episode/next?id=' + currentId + "&check_setting=true",
      Severity: Minor
      Found in public/js/nextEpisode.js - 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 badges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def badges
          options = []
      
          options << badge_options
          options << { type: :light, text: t("anime.shows.airing_status.#{@show.status}") } unless @show.air_complete?
      Severity: Minor
      Found in app/components/show_thumbnail_component.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

      Function login has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function login(error_p_id, waiting_p_id, success_p_id, form_id, callback) {
      Severity: Minor
      Found in app/assets/javascripts/login.js - About 35 mins to fix

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

            def override_episodes_for(show)
              #::Sync::Shows::ReactionCountJob.perform_later(show)
              return if show.reference_id.blank?
        
              response = RestClient.get(request_episodes_url(show))
        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

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

          def self.sort_filters(*filters)
            scope = all
            filters.map do |filter|
              scope = if filter.use_scope
                scope = scope.send(filter.use_scope)
        Severity: Minor
        Found in app/models/show.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 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

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