thedrummeraki/tanoshimu

View on GitHub

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

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

          function exitFullscreen() {
            if (document.exitFullscreen) {
              document.exitFullscreen();
              fullscreenOn = false;
            } else if (document.mozCancelFullScreen) {
      Severity: Major
      Found in app/assets/javascripts/episodes.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/episodes.js on lines 341..355

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

      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

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

          function enterFullscreen(video) {
            if (video.requestFullscreen) {
              video.requestFullscreen();
              fullscreenOn = true;
            } else if (video.mozRequestFullScreen) {
      Severity: Major
      Found in app/assets/javascripts/episodes.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/episodes.js on lines 357..371

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

      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

      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

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

                    if (hours > 0) {
                      hours = stringifyInts(hours) + ':'
                      $('time').children('.hours').show().text(hours);
                    } else {
                      $('time').children('.hours').hide();
              Severity: Major
              Found in app/assets/javascripts/episodes.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/episodes.js on lines 219..224

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

              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

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

                    if (hours > 0) {
                      hours = stringifyInts(hours) + ':'
                      $('time').children('.hours').show().text(hours);
                    } else {
                      $('time').children('.hours').hide();
              Severity: Major
              Found in app/assets/javascripts/episodes.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/episodes.js on lines 191..196

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

              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

              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

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

                  def execute
                    variables = prepare_variables(params[:variables])
                    query = params[:query]
                    operation_name = params[:operationName]
                
                
                Severity: Major
                Found in app/controllers/graphql_controller.rb and 1 other location - About 1 hr to fix
                app/controllers/admin/graphql_controller.rb on lines 9..29

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

                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

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

                  def execute
                    variables = prepare_variables(params[:variables])
                    query = params[:query]
                    operation_name = params[:operationName]
                
                
                Severity: Major
                Found in app/controllers/admin/graphql_controller.rb and 1 other location - About 1 hr to fix
                app/controllers/graphql_controller.rb on lines 3..23

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

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