thedrummeraki/tanoshimu

View on GitHub

Showing 54 of 66 total issues

Class Show has 49 methods (exceeds 20 allowed). Consider refactoring.
Open

class Show < ApplicationRecord
  include ShowScopesConcern
  include LikeableConcern
  include TanoshimuUtils::Concerns::RespondToTypes
  include TanoshimuUtils::Concerns::ResourceFetch
Severity: Minor
Found in app/models/show.rb - About 6 hrs to fix

    File show.rb has 356 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'active_storage'
    
    class Show < ApplicationRecord
      include ShowScopesConcern
      include LikeableConcern
    Severity: Minor
    Found in app/models/show.rb - About 4 hrs to fix

      File episodes.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      $(document).ready(function() {
        // Global variables
        var goingToShow = false;
        var goingToEpisode = false;
        var fullscreenOn = false;
      Severity: Minor
      Found in app/assets/javascripts/episodes.js - About 3 hrs to fix

        Function login has 93 lines of code (exceeds 25 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: Major
        Found in app/assets/javascripts/login.js - About 3 hrs to fix

          Function Config has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          var Config = (function() {
          
              function getParameterByName(name, url) {
                  if (!url) url = window.location.href;
                  name = name.replace(/[\[\]]/g, "\\$&");
          Severity: Minor
          Found in public/js/config.js - About 3 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

          Class BaseCategory has 27 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class BaseCategory
                LAYOUTS = %i(
                  simple
                  expanded
                ).freeze
          Severity: Minor
          Found in app/models/home/categories/base_category.rb - About 3 hrs to fix

            Function fetchComments has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            function fetchComments() {
                $.ajax({
                    type: 'get',
                    data: 'usernames=true',
                    url: '/json/episodes/get_comments?id=' + episodeId,
            Severity: Minor
            Found in public/js/comments.js - 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

            Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(api) {
              var validEnv = ['development', 'test', 'production']
              var currentEnv = api.env()
              var isDevelopmentEnv = api.env('development')
              var isProductionEnv = api.env('production')
            Severity: Major
            Found in babel.config.js - About 2 hrs to fix

              Function fetchComments has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function fetchComments() {
                  $.ajax({
                      type: 'get',
                      data: 'usernames=true',
                      url: '/json/episodes/get_comments?id=' + episodeId,
              Severity: Minor
              Found in public/js/comments.js - About 1 hr to fix

                Method create_or_update_show_for has 46 lines of code (exceeds 25 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 1 hr to fix

                  Function Config has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  var Config = (function() {
                  
                      function getParameterByName(name, url) {
                          if (!url) url = window.location.href;
                          name = name.replace(/[\[\]]/g, "\\$&");
                  Severity: Minor
                  Found in public/js/config.js - About 1 hr to fix

                    Method fetch_all_shows has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def fetch_all_shows
                              shows = []
                              @current_page = 1
                    
                              loop do
                    Severity: Minor
                    Found in app/operations/shows/kitsu/sync/shows_per_page.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 success has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            success: function(message) {
                                if (message.err) {
                                    console.log('Could not retrieve the comments: ' + message.err);
                                    commentTitle.html('Comments are unavailable.');
                                } else {
                    Severity: Minor
                    Found in public/js/comments.js - About 1 hr to fix

                      Method badges has 37 lines of code (exceeds 25 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 1 hr to fix

                        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

                          Severity
                          Category
                          Status
                          Source
                          Language