thedrummeraki/tanoshimu

View on GitHub

Showing 66 of 66 total issues

Method compute_shows has a Cognitive Complexity of 12 (exceeds 5 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

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 createMenuItem has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function createMenuItem(id, lang, label) {
      var listItem = document.createElement('li');

      var button = listItem.appendChild(document.createElement('button'));
      button.setAttribute('id', id);
Severity: Minor
Found in app/assets/javascripts/episodes.js - About 1 hr to fix

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

        def crawl_shows
          raise 'Crawling is not allowed.' unless Rails.configuration.allows_crawling
    
          @current_url = "https://kitsu.io/api/edge/anime?page%5Blimit%5D=20&page%5Boffset%5D=0"
          @has_next = true
    Severity: Minor
    Found in app/operations/shows/sync.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 airing_status_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def airing_status_for(show, default: 'unknown')
          return default if show.starts_on.blank?
    
          today_s_date = DateTime.now.utc
          if show.starts_on < today_s_date
    Severity: Minor
    Found in app/operations/shows/sync.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 fetch_streaming_platforms_from_anilist has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def fetch_streaming_platforms_from_anilist
            Rails.logger.info("[Shows::Anilist::Streamers] GET graphql.anilist.co: ANIME(##{anilist_id})")
            data = fetch_data!.dig(:data, :Media)
            return unless data.present?
    
    
    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 detect_from has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.detect_from(urls_or_names)
        urls_or_names = Array(urls_or_names) unless urls_or_names.is_a?(Array)
    
        names = urls_or_names.map do |url_or_name|
          if url_or_name.is_a?(String) || url_or_name.is_a?(Symbol)
    Severity: Minor
    Found in app/models/platform.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 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

          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/admin/graphql_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/graphql_controller.rb on lines 32..47

          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 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

          Severity
          Category
          Status
          Source
          Language