fastladder/fastladder

View on GitHub
app/assets/javascripts/lib/reader/main.js

Summary

Maintainability
F
6 days
Test Coverage

File main.js has 1025 lines of code (exceeds 250 allowed). Consider refactoring.
Open

window.onload   = init;
window.onresize = function(){LDR.invoke_hook('WINDOW_RESIZE')};

var app = LDR.Application.getInstance();

Severity: Major
Found in app/assets/javascripts/lib/reader/main.js - About 2 days to fix

    Function update has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        update: function(reload_flag){
            if(!LDR.VARS.USE_PARTIAL_LOAD){
                return this._update.apply(this, arguments);
            }
            var self = this;
    Severity: Minor
    Found in app/assets/javascripts/lib/reader/main.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

    Function update has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        update: function(reload_flag){
            if(!LDR.VARS.USE_PARTIAL_LOAD){
                return this._update.apply(this, arguments);
            }
            var self = this;
    Severity: Major
    Found in app/assets/javascripts/lib/reader/main.js - About 3 hrs to fix

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

      function init(){
          app.load({}, function(){
              LDR.setup_hook();
              LDR.invoke_hook('BEFORE_INIT');
              window.onerror = function(a,b,c){
      Severity: Major
      Found in app/assets/javascripts/lib/reader/main.js - About 2 hrs to fix

        Function get_unread has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function get_unread(id,callback){
            app.state.viewrange.start = 0;
            app.state.has_next = true;
            var api_url = '/api/unread';
            function has_cache(){
        Severity: Minor
        Found in app/assets/javascripts/lib/reader/main.js - About 1 hr to fix

          Function format_keybind has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function format_keybind(){
              var help = [];
              var kbd = function(str){
                  var list = str.split("|");
                  if(!app.state.keyhelp_more){list = [list[0]]};
          Severity: Minor
          Found in app/assets/javascripts/lib/reader/main.js - About 1 hr to fix

            Function getStyle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function getStyle(element, style){
                element = _$(element);
                var value = element.style[style.camelize()];
                if (!value) {
                    if (document.defaultView && document.defaultView.getComputedStyle) {
            Severity: Minor
            Found in app/assets/javascripts/lib/reader/main.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

            Function print_discover has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function print_discover(list){
                var output = _$("discover_items");
                var sub   = Template.get("discover_select_sub").compile()
                var unsub = Template.get("discover_select_unsub").compile()
                if(list.length == 0){
            Severity: Minor
            Found in app/assets/javascripts/lib/reader/main.js - About 1 hr to fix

              Function get_unread has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function get_unread(id,callback){
                  app.state.viewrange.start = 0;
                  app.state.has_next = true;
                  var api_url = '/api/unread';
                  function has_cache(){
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.js - 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

              Function print_discover has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function print_discover(list){
                  var output = _$("discover_items");
                  var sub   = Template.get("discover_select_sub").compile()
                  var unsub = Template.get("discover_select_unsub").compile()
                  if(list.length == 0){
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.js - 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

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

              function check_wait(){
                  if(app.config.use_wait != 1) return false;
                  var st = check_wait.state;
                  var key = Keybind.lastInput;
                  // 初回
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.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

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

              QueryCSS.findParent = function(rule,element){
                  elememt = _$(element);
                  if(!isFunction(rule)){
                      rule = rule.isQueryCSS ? rule : new QueryCSS(rule).match;
                  }
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.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

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

              function get_next(){
                  var sid = app.state.now_reading;
                  if(!sid && Ordered.list){
                      return Ordered.list[0];
                  }
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/lib/reader/main.js on lines 420..430

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

              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 get_prev(){
                  var sid = app.state.now_reading;
                  if(!sid && Ordered.list){
                      return Ordered.list[0];
                  }
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/lib/reader/main.js on lines 408..418

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

              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

                      if(L.LOADICON_NUM > 1){
                          var n = 1 + Math.floor(Math.rand(L.LOADICON_NUM));
                          path += "loading" + n + ".gif";
                      } else {
                          path += "loading.gif";
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/lib/reader/main.js on lines 812..817

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

              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

                      if(L.RESTICON_NUM > 1){
                          var n = 1 + Math.floor(Math.rand(L.RESTICON_NUM));
                          path += "rest" + n + ".gif";
                      } else {
                          path += "rest.gif";
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/lib/reader/main.js on lines 800..805

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

              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

                  var i = list.indexOfA(function(sid){
                      var item = subs_item(sid);
                      return (item.unread_count && app.state.now_reading != item.subscribe_id);
                  });
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/lib/reader/main.js on lines 388..391

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

              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

                  var i = list.indexOfA(function(sid){
                      var item = subs_item(sid);
                      return (item.unread_count && app.state.now_reading != item.subscribe_id);
                  });
              Severity: Major
              Found in app/assets/javascripts/lib/reader/main.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/lib/reader/main.js on lines 400..403

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

              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 3 locations. Consider refactoring.
              Open

              var SubsItem = new (Class.base(ListItem).extend({
                  focus_class  : "fs-focus",
                  focus_style  : { },
                  normal_style : { }
              }));
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.js and 2 other locations - About 40 mins to fix
              app/assets/javascripts/lib/reader/main.js on lines 435..439
              app/assets/javascripts/lib/reader/main.js on lines 443..447

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

              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 3 locations. Consider refactoring.
              Open

              var PinItem = new (Class.base(ListItem).extend({
                  focus_class  : "pin-focus",
                  focus_style  : { },
                  normal_style : { }
              }));
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.js and 2 other locations - About 40 mins to fix
              app/assets/javascripts/lib/reader/main.js on lines 435..439
              app/assets/javascripts/lib/reader/main.js on lines 451..455

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

              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 3 locations. Consider refactoring.
              Open

              var MenuItem = new (Class.base(ListItem).extend({
                  focus_class  : "menu-focus",
                  focus_style  : { },
                  normal_style : { }
              }));
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/main.js and 2 other locations - About 40 mins to fix
              app/assets/javascripts/lib/reader/main.js on lines 443..447
              app/assets/javascripts/lib/reader/main.js on lines 451..455

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

              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

              There are no issues that match your filters.

              Category
              Status