AllMangasReader-dev/AMR

View on GitHub
js/bookmarks.js

Summary

Maintainability
F
6 days
Test Coverage

File bookmarks.js has 528 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var mirrors;
var bmsAll;
function openTab(urlToOpen) {
  "use strict";
  chrome.runtime.sendMessage({
Severity: Major
Found in js/bookmarks.js - About 1 day to fix

Function filter has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function filter() {
    "use strict";
    var isOk = true,
        tmpLst = [],
        found = false,
Severity: Minor
Found in js/bookmarks.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 renderManga has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function renderManga(lstBms) {
    "use strict";
    var divChaps,
        divScans,
        parity = 0,
Severity: Major
Found in js/bookmarks.js - About 3 hrs to fix

Function renderManga has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function renderManga(lstBms) {
    "use strict";
    var divChaps,
        divScans,
        parity = 0,
Severity: Minor
Found in js/bookmarks.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 createScan has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createScan(obj, where) {
    "use strict";
    var divImg = $("<div class='scanDiv'></div>");
    divImg.data("mirror", obj.mirror);
    divImg.data("url", obj.url);
Severity: Major
Found in js/bookmarks.js - About 2 hrs to fix

Function load has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function load() {
    "use strict";
    var i;
    loadMenu("bookmarks");
    $(".showInit").show();
Severity: Minor
Found in js/bookmarks.js - About 2 hrs to fix

Function loadBookmarks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function loadBookmarks() {
    "use strict";
    if (localStorage.bookmarkMangasSearch !== undefined) {
        $("#searchBoxInput").val(localStorage.bookmarkMangasSearch);
    }
Severity: Minor
Found in js/bookmarks.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 filter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function filter() {
    "use strict";
    var isOk = true,
        tmpLst = [],
        found = false,
Severity: Minor
Found in js/bookmarks.js - About 1 hr to fix

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

function loadBookmarks() {
    "use strict";
    if (localStorage.bookmarkMangasSearch !== undefined) {
        $("#searchBoxInput").val(localStorage.bookmarkMangasSearch);
    }
Severity: Minor
Found in js/bookmarks.js - About 1 hr to fix

Function createPopupBM has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createPopupBM() {
    "use strict";
    var divData = $("<div id='bookmarkData' style='display:none'></div>");
    $("<span>This div is used to store data for AMR</span>").appendTo(divData);
    divData.appendTo($(document.body));
Severity: Minor
Found in js/bookmarks.js - About 1 hr to fix

Function setMirrorState has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setMirrorState(mirrorName, state) {
    "use strict";
    if (localStorage.bookmarkMirrorsState !== undefined) {
        var obj = JSON.parse(localStorage.bookmarkMirrorsState),
            isFound = false,
Severity: Minor
Found in js/bookmarks.js - About 1 hr to fix

Function load has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function load() {
    "use strict";
    var i;
    loadMenu("bookmarks");
    $(".showInit").show();
Severity: Minor
Found in js/bookmarks.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 deleteBM has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function deleteBM(dataElt) {
    "use strict";
    var textDesc,
        res;
    if (dataElt.data("type") === "chapter") {
Severity: Minor
Found in js/bookmarks.js - About 1 hr to fix

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

function setMirrorState(mirrorName, state) {
    "use strict";
    if (localStorage.bookmarkMirrorsState !== undefined) {
        var obj = JSON.parse(localStorage.bookmarkMirrorsState),
            isFound = false,
Severity: Minor
Found in js/bookmarks.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

Avoid too many return statements within this function.
Open

            return compareTo(a.chapterUrl, b.chapterUrl);
Severity: Major
Found in js/bookmarks.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return compareTo(a.name, b.name);
Severity: Major
Found in js/bookmarks.js - About 30 mins to fix

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

function isMirrorEnable(mirrorName) {
    "use strict";
    if (localStorage.bookmarkMirrorsState !== undefined) {
        var obj = JSON.parse(localStorage.bookmarkMirrorsState),
            i;
Severity: Minor
Found in js/bookmarks.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

    if ($("#bookmarkData").data("type") === "chapter") {
        textDesc = "Bookmark chapter '" + $("#bookmarkData").data("chapName") + "' of '" + $("#bookmarkData").data("name") + "' on '" + $("#bookmarkData").data("mirror");
        textDesc += "'. You can add notes below which will be associated with this bookmark.";
    } else {
        textDesc = "Bookmark scan '" + $("#bookmarkData").data("scanName") + "' of chapter '" + $("#bookmarkData").data("chapName") + "' of '" + $("#bookmarkData").data("name") + "' on '" + $("#bookmarkData").data("mirror");
Severity: Major
Found in js/bookmarks.js and 1 other location - About 7 hrs to fix
js/back.js on lines 318..324

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

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

    $(".ongletCont").each(function (index) {
        if ($(this).attr("id") === tab) {
            $(this).show();
        } else {
            $(this).hide();
Severity: Major
Found in js/bookmarks.js and 1 other location - About 2 hrs to fix
js/options.js on lines 116..122

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

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

            aMod.click(function () {
                modifyBM($(this).parent().parent().parent().parent().parent());
                return false;
            });
Severity: Major
Found in js/bookmarks.js and 1 other location - About 1 hr to fix
js/bookmarks.js on lines 396..399

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

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

            aDel.click(function () {
                deleteBM($(this).parent().parent().parent().parent().parent());
                return false;
            });
Severity: Major
Found in js/bookmarks.js and 1 other location - About 1 hr to fix
js/bookmarks.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 65.

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

    aMod.click(function () {
        modifyBM($(this).parent().parent().parent().parent());
        return false;
    });
Severity: Major
Found in js/bookmarks.js and 1 other location - About 1 hr to fix
js/bookmarks.js on lines 308..311

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

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

    aDel.click(function () {
        deleteBM($(this).parent().parent().parent().parent());
        return false;
    });
Severity: Major
Found in js/bookmarks.js and 1 other location - About 1 hr to fix
js/bookmarks.js on lines 300..303

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

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