blinkjs/blink

View on GitHub

Showing 38 of 38 total issues

Function Formatter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

var Formatter = (function () {
    function Formatter() {
    }
    Formatter.prototype.format = function (config, rules) {
        if (typeof rules === 'undefined') {
Severity: Minor
Found in js/lib/Formatter.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

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

    public set style(value: string) {
        value = value.toLowerCase();
        if (!styles.hasOwnProperty(value)) {
            throw new Error('Unsupported style: ' + value);
        }
Severity: Major
Found in lib/browser/Configuration.ts and 3 other locations - About 1 hr to fix
lib/Configuration.ts on lines 53..59
lib/browser/Configuration.ts on lines 142..148
lib/browser/Configuration.ts on lines 154..160

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

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

    public set newline(value: string) {
        value = value.toLowerCase();
        if (!newlines.hasOwnProperty(value)) {
            throw new Error('Unsupported newline: ' + value);
        }
Severity: Major
Found in lib/browser/Configuration.ts and 3 other locations - About 1 hr to fix
lib/Configuration.ts on lines 53..59
lib/browser/Configuration.ts on lines 98..104
lib/browser/Configuration.ts on lines 154..160

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

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

    set newline(value: string) {
        value = value.toLowerCase();
        if (!newlines.hasOwnProperty(value)) {
            throw new Error('Unsupported newline: ' + value);
        }
Severity: Major
Found in lib/Configuration.ts and 3 other locations - About 1 hr to fix
lib/browser/Configuration.ts on lines 98..104
lib/browser/Configuration.ts on lines 142..148
lib/browser/Configuration.ts on lines 154..160

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

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

var Compiler = (function () {
    function Compiler(config) {
        this.config = config;
    }
    Compiler.prototype.compile = function (rules) {
Severity: Minor
Found in js/lib/Compiler.js - About 1 hr to fix

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

        Rule.prototype.resolveTree = function (selectors, body, seed, key) {
            var _this = this;
            seed = seed || {};
            key = key || '';
            Object.keys(body).forEach(function (k2) {
    Severity: Minor
    Found in js/lib/Rule.js - About 1 hr to fix

      Function resolveTree has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private resolveTree(selectors: string, body: any, seed?: any, key?: string) {
              seed = seed || {};
              key = key || '';
              Object.keys(body).forEach(k2 => {
                  if (k2 === 'respond') {
      Severity: Minor
      Found in lib/Rule.ts - About 1 hr to fix

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

        var Element = (function () {
            function Element(name, body) {
                this.name = name;
                this.body = body;
            }
        Severity: Minor
        Found in js/lib/BEM.js - About 1 hr to fix

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

          var Modifier = (function () {
              function Modifier(name, body) {
                  this.name = name;
                  this.body = body;
              }
          Severity: Minor
          Found in js/lib/BEM.js - About 1 hr to fix

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

                set modifier(value: string) {
                    if (value.indexOf('%s') === -1) {
                        throw new Error('Invalid modifier format. Expected "%s".');
                    }
                    this.raw.modifier = value;
            Severity: Major
            Found in lib/browser/Configuration.ts and 2 other locations - About 1 hr to fix
            lib/browser/Configuration.ts on lines 192..197
            lib/browser/Configuration.ts on lines 203..208

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

            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

                set block(value: string) {
                    if (value.indexOf('%s') === -1) {
                        throw new Error('Invalid block format. Expected "%s".');
                    }
                    this.raw.block = value;
            Severity: Major
            Found in lib/browser/Configuration.ts and 2 other locations - About 1 hr to fix
            lib/browser/Configuration.ts on lines 203..208
            lib/browser/Configuration.ts on lines 214..219

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

            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

                set element(value: string) {
                    if (value.indexOf('%s') === -1) {
                        throw new Error('Invalid element format. Expected "%s".');
                    }
                    this.raw.element = value;
            Severity: Major
            Found in lib/browser/Configuration.ts and 2 other locations - About 1 hr to fix
            lib/browser/Configuration.ts on lines 192..197
            lib/browser/Configuration.ts on lines 214..219

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

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

            var Configuration = (function (_super) {
                __extends(Configuration, _super);
                function Configuration(options) {
                    _super.call(this, options);
                    this.set(require('../../defaults.json'));
            Severity: Minor
            Found in js/lib/Configuration.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

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

                        gulp.src(['js/test/*.js', 'js/test/spec/**/*.js'], { read: false })
                            .pipe(plumber())
                            .pipe(mocha({
                                reporter: 'spec',
                                clearRequireCache: true
            Severity: Minor
            Found in tasks/test.js and 1 other location - About 55 mins to fix
            tasks/test--watch.js on lines 6..11

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

            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

                return gulp.src(['js/test/*.js', 'js/test/spec/**/*.js'], { read: false })
                    .pipe(plumber())
                    .pipe(mocha({
                        reporter: 'min',
                        clearRequireCache: true
            Severity: Minor
            Found in tasks/test--watch.js and 1 other location - About 55 mins to fix
            tasks/test.js on lines 10..15

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

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

                private compilePrimitive(value: any) {
                    switch (typeof value) {
                        case 'number':
                            if (value === 0) {
                                return '0';
            Severity: Minor
            Found in lib/Rule.ts - 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

            Avoid too many return statements within this function.
            Open

                    return value;
            Severity: Major
            Found in lib/Rule.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return value;
              Severity: Major
              Found in js/lib/Rule.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language