albanm/node-libxslt

View on GitHub

Showing 17 of 17 total issues

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

Stylesheet.prototype.apply = function(source, params, options, callback) {
    // params and options parameters are optional
    if (typeof options === 'function') {
        callback = options;
        options = {};
Severity: Minor
Found in index.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

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

var applyAsyncParallelStr = function(iterations, callback) {
    var i = 0;
    async.eachLimit(new Array(iterations), 10, function(u, callbackEach) {
        stylesheet.apply(docStr, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 57..65
benchmark.js on lines 67..75
benchmark.js on lines 121..129

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

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

var stylesheetAsyncParallelParsingObj = function(iterations, callback) {
    var i = 0;
    async.eachLimit(new Array(iterations), 10, function(u, callbackEach) {
        libxslt.parse(stylesheetObj, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 57..65
benchmark.js on lines 111..119
benchmark.js on lines 121..129

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

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

var applyAsyncParallelObj = function(iterations, callback) {
    var i = 0;
    async.eachLimit(new Array(iterations), 10, function(u, callbackEach) {
        stylesheet.apply(docObj, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 57..65
benchmark.js on lines 67..75
benchmark.js on lines 111..119

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

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

var stylesheetAsyncParallelParsingStr = function(iterations, callback) {
    var i = 0;
    async.eachLimit(new Array(iterations), 10, function(u, callbackEach) {
        libxslt.parse(stylesheetStr, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 67..75
benchmark.js on lines 111..119
benchmark.js on lines 121..129

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

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

var applyAsyncSeriesStr = function(iterations, callback) {
    var i = 0;
    async.eachSeries(new Array(iterations), function(u, callbackEach) {
        stylesheet.apply(docStr, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 37..45
benchmark.js on lines 47..55
benchmark.js on lines 101..109

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

var applyAsyncSeriesObj = function(iterations, callback) {
    var i = 0;
    async.eachSeries(new Array(iterations), function(u, callbackEach) {
        stylesheet.apply(docObj, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 37..45
benchmark.js on lines 47..55
benchmark.js on lines 91..99

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

var stylesheetAsyncSeriesParsingStr = function(iterations, callback) {
    var i = 0;
    async.eachSeries(new Array(iterations), function(u, callbackEach) {
        libxslt.parse(stylesheetStr, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 47..55
benchmark.js on lines 91..99
benchmark.js on lines 101..109

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

var stylesheetAsyncSeriesParsingObj = function(iterations, callback) {
    var i = 0;
    async.eachSeries(new Array(iterations), function(u, callbackEach) {
        libxslt.parse(stylesheetObj, function(err, result) {
            i++;
Severity: Major
Found in benchmark.js and 3 other locations - About 2 hrs to fix
benchmark.js on lines 37..45
benchmark.js on lines 91..99
benchmark.js on lines 101..109

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

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

function report(pkg, configs, inputs, archs) {
    archs.forEach(function(arch, index) {
        console.log((index + 1) + ": " + arch.os + " / " + arch.arch);
    });
    configs.forEach(function(config) {
Severity: Minor
Found in deps/checkdep.js - About 1 hr to fix

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

    Stylesheet.prototype.apply = function(source, params, options, callback) {
        // params and options parameters are optional
        if (typeof options === 'function') {
            callback = options;
            options = {};
    Severity: Minor
    Found in index.js - About 1 hr to fix

      Function deps has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function deps(pkg, configs, callback) {
          var central = new Semaphore();
          var indir = path.join(__dirname, pkg);
          var confdir = path.join(__dirname, pkg + ".config");
          var archs = [];
      Severity: Minor
      Found in deps/checkdep.js - About 1 hr to fix

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

        var stylesheetSyncParsingObj = function(iterations, callback) {
            for (var i = 0; i < iterations; i++) {
                libxslt.parse(stylesheetObj);
            }
            callback();
        Severity: Major
        Found in benchmark.js and 3 other locations - About 55 mins to fix
        benchmark.js on lines 23..28
        benchmark.js on lines 77..82
        benchmark.js on lines 84..89

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

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

        var applySyncStr = function(iterations, callback) {
            for (var i = 0; i < iterations; i++) {
                stylesheet.apply(docStr);
            }
            callback();
        Severity: Major
        Found in benchmark.js and 3 other locations - About 55 mins to fix
        benchmark.js on lines 23..28
        benchmark.js on lines 30..35
        benchmark.js on lines 84..89

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

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

        var applySyncObj = function(iterations, callback) {
            for (var i = 0; i < iterations; i++) {
                stylesheet.apply(docObj);
            }
            callback();
        Severity: Major
        Found in benchmark.js and 3 other locations - About 55 mins to fix
        benchmark.js on lines 23..28
        benchmark.js on lines 30..35
        benchmark.js on lines 77..82

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

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

        var stylesheetSyncParsingStr = function(iterations, callback) {
            for (var i = 0; i < iterations; i++) {
                libxslt.parse(stylesheetStr);
            }
            callback();
        Severity: Major
        Found in benchmark.js and 3 other locations - About 55 mins to fix
        benchmark.js on lines 30..35
        benchmark.js on lines 77..82
        benchmark.js on lines 84..89

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

        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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.parse = function(source, callback) {
            // stylesheet can be given as a string or a pre-parsed xml document
            if (typeof source === 'string') {
                try {
                    source = libxmljs.parseXml(source, { nocdata: true });
        Severity: Minor
        Found in index.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

        Severity
        Category
        Status
        Source
        Language