vampireneo/Book

View on GitHub

Showing 47 of 47 total issues

File isbn.js has 2055 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//
// isbn.js
//
// The MIT License
// Copyright (c) 2007, 2010 hetappi <hetappi.pm (a) gmail.com>
Severity: Major
Found in utility/isbn.js - About 5 days to fix

    Function createServer has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var createServer = function(portNo) {
      var app = express();
      app.locals.pretty = true;
      app.set('views', __dirname + '/views');
      app.set('view engine', 'pug');
    Severity: Major
    Found in main.js - About 4 hrs to fix

      Function getByISBN has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.getByISBN = function(pISBN) {
        var domain = 'http://search.books.com.tw';
        var searchUrl = '/exep/prod_search.php?cat=BKA&key=';
        var bookObj = {};
        var deferred = Q.defer();
      Severity: Major
      Found in bookParser/Books.js - About 4 hrs to fix

        Function getByISBN has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.getByISBN = function(pISBN) {
          var domain = 'http://www.eslite.com/';
          var searchUrl = 'Search_BW.aspx?query=';
          var bookObj = {};
          var deferred = Q.defer();
        Severity: Major
        Found in bookParser/Eslite.js - About 3 hrs to fix

          Function merge has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function merge(target, src) {
            var array = Array.isArray(src) || Array.isArray(target);
            var dst = (array && []) || {};
          
            if (array) {
          Severity: Minor
          Found in utility/merge.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 getByISBN has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.getByISBN = function(pISBN) {
            var domain = 'http://www.hkbookcity.com/';
            var searchUrl = 'searchbook2.php?startnum=1&key=isbn&keyword=';
            var bookObj = {};
            var deferred = Q.defer();
          Severity: Major
          Found in bookParser/HkBookCity.js - About 3 hrs to fix

            Function getByISBN has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.getByISBN = function(pISBN) {
              var domain = 'http://m.kingstone.com.tw';
              var searchUrl = '/search.asp?q=';
              var bookObj = {};
              var deferred = Q.defer();
            Severity: Major
            Found in bookParser/Kingstone.js - About 2 hrs to fix

              Function getByISBN has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.getByISBN = function(pISBN) {
                var domain = 'http://www.jointpublishing.com';
                var searchUrl =
                  '/Special-Page/search-result.aspx?searchmode=anyword&searchtext=';
                var bookObj = {};
              Severity: Major
              Found in bookParser/JointPublishing.js - About 2 hrs to fix

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

                    if (src.forEach) {
                      src.forEach(function(e, i) {
                        if (typeof target[i] === 'undefined') {
                          if (target.indexOf(e) === -1) {
                            dst.push(e);
                Severity: Major
                Found in utility/merge.js and 1 other location - About 2 hrs to fix
                utility/merge.js on lines 14..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 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

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

                        } else if (typeof e === 'object' && !(e instanceof Date)) {
                          dst[i] = merge(target[i], e);
                        } else {
                          if (
                            (!(e instanceof Date) && dst.indexOf(e) === -1) ||
                Severity: Major
                Found in utility/merge.js and 1 other location - About 2 hrs to fix
                utility/merge.js on lines 8..32

                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 merge has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function merge(target, src) {
                  var array = Array.isArray(src) || Array.isArray(target);
                  var dst = (array && []) || {};
                
                  if (array) {
                Severity: Major
                Found in utility/merge.js - About 2 hrs to fix

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

                  exports.getByISBN = function(pISBN) {
                    var searchUrl = 'http://www.cp1897.com.hk/product_info.php?BookId=';
                    var bookObj = {};
                    var deferred = Q.defer();
                  
                  
                  Severity: Major
                  Found in bookParser/CommercialPress.js - About 2 hrs to fix

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

                        parse: function(val) {
                          var ret;
                          // correct for misplaced hyphens
                          // val = val.replace(/ -/,'');
                          ret = val.match(/^\d{9}[\dX]$/) ?
                    Severity: Minor
                    Found in utility/isbn.js - About 2 hrs to fix

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

                                    var title = text[0].replace(/\s/g, '').trim(),
                                      content = text[1]
                                      .trim()
                                      .replace(/\s+/g, ' ')
                                      .trim()
                      Severity: Major
                      Found in bookParser/Books.js and 1 other location - About 1 hr to fix
                      bookParser/Books.js on lines 80..85

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

                                    var title2 = text2[0].replace(/\s/g, '').trim(),
                                      content2 = text2[1]
                                      .trim()
                                      .replace(/\s+/g, ' ')
                                      .trim()
                      Severity: Major
                      Found in bookParser/Books.js and 1 other location - About 1 hr to fix
                      bookParser/Books.js on lines 50..55

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

                                } else if (text.indexOf('譯者') !== -1) {
                                  bookObj.Translater = value;
                                } else if (text.indexOf('出版社') !== -1) {
                                  bookObj.Publisher = value;
                                } else if (text.indexOf('ISBN') !== -1) {
                      Severity: Major
                      Found in bookParser/CommercialPress.js and 1 other location - About 1 hr to fix
                      bookParser/CommercialPress.js on lines 48..54

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

                      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

                                } else if (text.indexOf('頁數') !== -1) {
                                  bookObj.Pages = value.replace(/頁/g, '').trim();
                                } else if (text.indexOf('裝幀') !== -1) {
                                  bookObj.Spec = value;
                                } else if (text.indexOf('叢書/系列') !== -1) {
                      Severity: Major
                      Found in bookParser/CommercialPress.js and 1 other location - About 1 hr to fix
                      bookParser/CommercialPress.js on lines 29..35

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

                      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 fill has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          fill: function(codes) {
                            var rec, prefix, ck10, ck13, parts13, parts10;
                      
                            if (!codes) {
                              return null;
                      Severity: Minor
                      Found in utility/isbn.js - About 1 hr to fix

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

                              '84': {
                                name: 'Spain',
                                ranges: [
                                  ['00', '19'],
                                  ['200', '699'],
                        Severity: Major
                        Found in utility/isbn.js and 2 other locations - About 1 hr to fix
                        utility/isbn.js on lines 437..451
                        utility/isbn.js on lines 492..506

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

                        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

                              '952': {
                                name: 'Finland',
                                ranges: [
                                  ['00', '19'],
                                  ['200', '499'],
                        Severity: Major
                        Found in utility/isbn.js and 2 other locations - About 1 hr to fix
                        utility/isbn.js on lines 297..311
                        utility/isbn.js on lines 492..506

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language