AllMangasReader-dev/AMR

View on GitHub
js/mgEntry.js

Summary

Maintainability
F
5 days
Test Coverage

File mgEntry.js has 565 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**

  This file is part of All Mangas Reader.

  All Mangas Reader is free software: you can redistribute it and/or modify
Severity: Major
Found in js/mgEntry.js - About 1 day to fix

Function updateWebsitesFromRepository has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateWebsitesFromRepository(callback) {
  "use strict";
  $.ajax({
     type: 'GET',
     url: amrc_repository + "websites.json",
Severity: Major
Found in js/mgEntry.js - About 3 hrs to fix

Function success has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    success : function (resp) {
      //distant descriptions
      var wsdist = resp;
      //local description
      amrcsql.webdb.getWebsites(function (list) {
Severity: Major
Found in js/mgEntry.js - About 2 hrs to fix

Function releaseImplentationFromId has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function releaseImplentationFromId(id, callback) {
  "use strict";
  $.ajax({
    url : amrc_root + "service.php?name=implementation_getrelease_v2&id=" + id,
    beforeSend : function (xhr) {
Severity: Major
Found in js/mgEntry.js - About 2 hrs to fix

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

function importImplentationFromId(id, callback) {
  "use strict";
  $.ajax({
    url : amrc_root + "service.php?name=implementation_get_v2&id=" + id,
    beforeSend : function (xhr) {
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

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

function getMirrorsDescription(callback) {
  "use strict";
  amrcsql.webdb.getWebsites(function (list) {
    var websites = list,
      mustUpdate = false,
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

Function success has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    success : function (resp) {
      //distant description
      var description = JSON.parse(resp);

      //local description
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

Function loadJSFromRepositoryForActivatedMirrors has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function loadJSFromRepositoryForActivatedMirrors(list, pos, input) {
  "use strict";
  chrome.extension.getBackgroundPage().isReady(false, "Downloading activated mirrors from repository");
  var docache = true;
  if (input.jsCode.indexOf(".php") !== -1) {
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

Function success has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    success : function (resp) {
      //distant description
      var description = JSON.parse(resp);

      //local description
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

Function doesCurrentPageMatchManga has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function doesCurrentPageMatchManga(url, activatedMirrors, callback) {
  "use strict";
  getMirrorsDescription(function (list) {
    var wsloc = list,
      isok = false,
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

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

function loadJSFromRepositoryForMirrors(list, pos, input) {
  "use strict";

  var docache = true;
  if (input.jsCode.indexOf(".php") !== -1) {
Severity: Minor
Found in js/mgEntry.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                if (!validURL(wsloc[j].jsCode)) {
                  // object correspond to old description (js code in database... switch to manifest 2)
                  console.log("Website " + wsdist[i].mirrorName + " has an old description... swintch to new one...");
                  var change = {
                    description : wsdist[i],
Severity: Major
Found in js/mgEntry.js - About 45 mins to fix

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

function waitForFinishRepository(websites, callback) {
  "use strict";
  chrome.extension.getBackgroundPage().isReady(false, "Waiting for mirrors to be loaded");
  var done = true,
    i;
Severity: Minor
Found in js/mgEntry.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

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

          if (params.shownotifws === 1) {
            var wsData = {
              ws : description.mirrorName,
              developer : description.developer,
              revision : description.revision,
Severity: Major
Found in js/mgEntry.js and 1 other location - About 1 hr to fix
js/mgEntry.js on lines 337..346

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

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

  if (params.shownotifws === 1) {
    var wsData = {
      ws : description.mirrorName,
      developer : description.developer,
      revision : description.revision,
Severity: Major
Found in js/mgEntry.js and 1 other location - About 1 hr to fix
js/mgEntry.js on lines 393..402

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

  for (i = 0; i < websites.length; i += 1) {
    if (!websites[i].loaded || websites[i].loaded === false) {
      done = false;
      break;
    }
Severity: Major
Found in js/mgEntry.js and 2 other locations - About 1 hr to fix
js/mgEntry.js on lines 257..262
js/mgEntry.js on lines 505..510

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

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

  for (i = 0; i < mirrors.length; i += 1) {
    if (!mirrors[i].loadedscript || mirrors[i].loadedscript === false) {
      done = false;
      break;
    }
Severity: Major
Found in js/mgEntry.js and 2 other locations - About 1 hr to fix
js/mgEntry.js on lines 106..111
js/mgEntry.js on lines 257..262

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

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

  for (i = 0; i < changes.length; i += 1) {
    if (!changes[i].loaded || changes[i].loaded === false) {
      done = false;
      break;
    }
Severity: Major
Found in js/mgEntry.js and 2 other locations - About 1 hr to fix
js/mgEntry.js on lines 106..111
js/mgEntry.js on lines 505..510

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

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

          for (j = 0; j < wsloc.length; j += 1) {
            if (description.mirrorName === wsloc[j].mirrorName) {
              found = wsloc[j];
              break;
            }
Severity: Major
Found in js/mgEntry.js and 1 other location - About 1 hr to fix
js/mgEntry.js on lines 368..373

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

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

          for (j = 0; j < wsloc.length; j += 1) {
            if (description.mirrorName === wsloc[j].mirrorName) {
              found = wsloc[j];
              break;
            }
Severity: Major
Found in js/mgEntry.js and 1 other location - About 1 hr to fix
js/mgEntry.js on lines 296..301

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

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