fastladder/fastladder

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

Summary

Maintainability
F
1 wk
Test Coverage

File commands.js has 984 lines of code (exceeds 250 allowed). Consider refactoring.
Open

function touch(id, state){
    if(app.config.touch_when == state){
        touch_all(id)
    }
}
Severity: Major
Found in app/assets/javascripts/lib/reader/commands.js - About 2 days to fix

    Control has 76 functions (exceeds 20 allowed). Consider refactoring.
    Open

    var Control = {
        pin: function(){
            var item = get_active_item(true);
            if(!item) return;
            toggle_pin(item.item_id);
    Severity: Major
    Found in app/assets/javascripts/lib/reader/commands.js - About 1 day to fix

      Function print_feed has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function print_feed(feed){
          LDR.invoke_hook('BEFORE_PRINTFEED', feed);
          var subscribe_id = feed.subscribe_id;
      
          app.state.last_feed = feed;
      Severity: Major
      Found in app/assets/javascripts/lib/reader/commands.js - About 4 hrs to fix

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

        function print_feed(feed){
            LDR.invoke_hook('BEFORE_PRINTFEED', feed);
            var subscribe_id = feed.subscribe_id;
        
            app.state.last_feed = feed;
        Severity: Minor
        Found in app/assets/javascripts/lib/reader/commands.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 get_active_item has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        function get_active_item(detail){
            // return 1;
            var sc = _$("right_container").scrollTop;
            var divs = _$("right_body").getElementsByTagName("h2");
            // for Opera9 beta
        Severity: Minor
        Found in app/assets/javascripts/lib/reader/commands.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 get_active_item has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function get_active_item(detail){
            // return 1;
            var sc = _$("right_container").scrollTop;
            var divs = _$("right_body").getElementsByTagName("h2");
            // for Opera9 beta
        Severity: Major
        Found in app/assets/javascripts/lib/reader/commands.js - About 2 hrs to fix

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

              pin_hover: function(e){
                  function stophide(){
                      if(app.state.pin_timer){ app.state.pin_timer.cancel() }
                  }
                  stophide();
          Severity: Minor
          Found in app/assets/javascripts/lib/reader/commands.js - About 1 hr to fix

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

                feed_page: function(num){
                    // 過去記事取得
                    var sid = app.state.now_reading;
                    if(!sid) return;
                    var limit;
            Severity: Minor
            Found in app/assets/javascripts/lib/reader/commands.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 mark_all_read has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mark_all_read: function(){
                    var list = Ordered.list;
                    if(!list) return;
                    var no_feeds = 'There is no item to mark as read';
                    if(list.length == 0){
            Severity: Minor
            Found in app/assets/javascripts/lib/reader/commands.js - About 1 hr to fix

              Function feed_page has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  feed_page: function(num){
                      // 過去記事取得
                      var sid = app.state.now_reading;
                      if(!sid) return;
                      var limit;
              Severity: Minor
              Found in app/assets/javascripts/lib/reader/commands.js - About 1 hr to fix

                Function show_folder has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    show_folder: function(){
                        Event.cancelNext("click");
                        var menu = FlatMenu.create_on(this, "right_container");
                        menu.show();
                        var write_menu = function(){
                Severity: Minor
                Found in app/assets/javascripts/lib/reader/commands.js - About 1 hr to fix

                  Function write_menu has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          var write_menu = function(){
                              menu.clear();
                              // 開く件数
                              var open_num = app.config.max_pin;
                              // containerの高さにあわせて調整
                  Severity: Minor
                  Found in app/assets/javascripts/lib/reader/commands.js - About 1 hr to fix

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

                        mark_all_read: function(){
                            var list = Ordered.list;
                            if(!list) return;
                            var no_feeds = 'There is no item to mark as read';
                            if(list.length == 0){
                    Severity: Minor
                    Found in app/assets/javascripts/lib/reader/commands.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

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

                        read_next_subs: function(){
                            if(app.state.requested) return;
                            var next = get_next();
                            if(next){
                                app.state.requested = true;
                    Severity: Minor
                    Found in app/assets/javascripts/lib/reader/commands.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 3 locations. Consider refactoring.
                    Open

                        read_prev_subs: function(){
                            if(app.state.requested) return;
                            var prev = get_prev();
                            if(prev){
                                app.state.requested = true;
                    Severity: Major
                    Found in app/assets/javascripts/lib/reader/commands.js and 2 other locations - About 2 hrs to fix
                    app/assets/javascripts/lib/reader/commands.js on lines 844..853
                    app/assets/javascripts/lib/reader/commands.js on lines 854..863

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

                    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

                        read_end_subs: function(){
                            if(app.state.requested) return;
                            var end = get_end();
                            if(end){
                                app.state.requested = true;
                    Severity: Major
                    Found in app/assets/javascripts/lib/reader/commands.js and 2 other locations - About 2 hrs to fix
                    app/assets/javascripts/lib/reader/commands.js on lines 844..853
                    app/assets/javascripts/lib/reader/commands.js on lines 882..891

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

                    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

                        read_head_subs: function(){
                            if(app.state.requested) return;
                            var head = get_head();
                            if(head){
                                app.state.requested = true;
                    Severity: Major
                    Found in app/assets/javascripts/lib/reader/commands.js and 2 other locations - About 2 hrs to fix
                    app/assets/javascripts/lib/reader/commands.js on lines 854..863
                    app/assets/javascripts/lib/reader/commands.js on lines 882..891

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

                    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

                            foreach(modes,function(v,i){
                                var item = tmpl({
                                    label : GLOBAL.viewModes[v],
                                    mode  : v,
                                    checked : app.config.view_mode == v ? "checked" : ""
                    Severity: Major
                    Found in app/assets/javascripts/lib/reader/commands.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/lib/reader/commands.js on lines 654..661

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

                    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

                            foreach(modes,function(v,i){
                                var item = tmpl({
                                    label : GLOBAL.sortModes[v],
                                    mode  : v,
                                    checked : app.config.sort_mode == v ? "checked" : ""
                    Severity: Major
                    Found in app/assets/javascripts/lib/reader/commands.js and 1 other location - About 2 hrs to fix
                    app/assets/javascripts/lib/reader/commands.js on lines 629..636

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

                    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