vesln/stylec

View on GitHub

Showing 32 of 32 total issues

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

MinLen.prototype.check = function(node) {
  var min = this.option();

  node.declarations.forEach(function(node) {
    if (node.id.name.length < min) {
Severity: Major
Found in lib/stylec/rule/var-min-len.js and 2 other locations - About 3 hrs to fix
lib/stylec/rule/obj-key-min-len.js on lines 28..36
lib/stylec/rule/var-max-len.js on lines 27..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 99.

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

MaxLen.prototype.check = function(node) {
  var max = this.option();

  node.declarations.forEach(function(node) {
    if (node.id.name.length > max) {
Severity: Major
Found in lib/stylec/rule/var-max-len.js and 2 other locations - About 3 hrs to fix
lib/stylec/rule/obj-key-min-len.js on lines 28..36
lib/stylec/rule/var-min-len.js on lines 27..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 99.

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

MinLen.prototype.check = function(node) {
  var min = this.option();

  node.properties.forEach(function(prop) {
    if (prop.key.name.length < min) {
Severity: Major
Found in lib/stylec/rule/obj-key-min-len.js and 2 other locations - About 3 hrs to fix
lib/stylec/rule/var-max-len.js on lines 27..35
lib/stylec/rule/var-min-len.js on lines 27..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 99.

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

exports.nodeChildren = function(node) {
  switch (node.type) {
    case 'AssignmentExpression':
      return [node.right, node.left];

Severity: Major
Found in lib/stylec/util.js - About 3 hrs to fix

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

    MaxLen.prototype.check = function(node) {
      if (!node.id) return;
    
      if (node.id.name.length > this.option()) {
        this.badToken(node);
    Severity: Major
    Found in lib/stylec/rule/fn-max-name.js and 1 other location - About 2 hrs to fix
    lib/stylec/rule/fn-min-name.js on lines 28..34

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

    MinLen.prototype.check = function(node) {
      if (!node.id) return;
    
      if (node.id.name.length < this.option()) {
        this.badToken(node);
    Severity: Major
    Found in lib/stylec/rule/fn-min-name.js and 1 other location - About 2 hrs to fix
    lib/stylec/rule/fn-max-name.js on lines 49..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 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

    Function parseOptions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Rule.prototype.parseOptions = function() {
      var val = this.source.option(this._option.key) || false;
      var error = false;
    
      if (val === false) {
    Severity: Minor
    Found in lib/stylec/rule.js - About 1 hr to fix

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

      var Comparison = Rule.create({
        error: 'Bad comparison operator',
      
        option: {
          key: 'comparison',
      Severity: Major
      Found in lib/stylec/rule/comparison.js and 1 other location - About 1 hr to fix
      lib/stylec/rule/array-trailing-comma.js on lines 39..51

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

      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 ArrayComma = Rule.create({
        error: 'Bad trailing array comma',
      
        option: {
          key: 'arrcomma',
      Severity: Major
      Found in lib/stylec/rule/array-trailing-comma.js and 1 other location - About 1 hr to fix
      lib/stylec/rule/comparison.js on lines 43..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 60.

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

      VarDec.prototype.multiLine = function(node, allowed, fn) {
        if (node.declarations.length === 1) {
          return this.onePerDec(node);
        }
      
      
      Severity: Minor
      Found in lib/stylec/rule/var-dec.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 parseOptions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      Rule.prototype.parseOptions = function() {
        var val = this.source.option(this._option.key) || false;
        var error = false;
      
        if (val === false) {
      Severity: Minor
      Found in lib/stylec/rule.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 multiLine has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      VarDec.prototype.multiLine = function(node, allowed, fn) {
        if (node.declarations.length === 1) {
          return this.onePerDec(node);
        }
      
      
      Severity: Minor
      Found in lib/stylec/rule/var-dec.js - About 1 hr to fix

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

        var VariableCase = Rule.create({
          error: 'Bad variable case',
        
          option: {
            key: 'varcase',
        Severity: Major
        Found in lib/stylec/rule/variable-case.js and 1 other location - About 1 hr to fix
        lib/stylec/rule/function-case.js on lines 8..20

        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

        var FunctionCase = Rule.create({
          error: 'Bad function case',
        
          option: {
            key: 'fncase',
        Severity: Major
        Found in lib/stylec/rule/function-case.js and 1 other location - About 1 hr to fix
        lib/stylec/rule/variable-case.js on lines 8..20

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

        var MinLen = Rule.create({
          error: 'The object key is too short',
        
          option: {
            key: 'okeymin',
        Severity: Major
        Found in lib/stylec/rule/obj-key-min-len.js and 3 other locations - About 1 hr to fix
        lib/stylec/rule/fn-max-params.js on lines 7..19
        lib/stylec/rule/fn-min-name.js on lines 7..19
        lib/stylec/rule/obj-key-max-len.js on lines 7..19

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

        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 MinLen = Rule.create({
          error: 'The function name is too short',
        
          option: {
            key: 'fnmin',
        Severity: Major
        Found in lib/stylec/rule/fn-min-name.js and 3 other locations - About 1 hr to fix
        lib/stylec/rule/fn-max-params.js on lines 7..19
        lib/stylec/rule/obj-key-max-len.js on lines 7..19
        lib/stylec/rule/obj-key-min-len.js on lines 7..19

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

        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 MaxParams = Rule.create({
          error: 'The function has too many parameters',
        
          option: {
            key: 'fnparams',
        Severity: Major
        Found in lib/stylec/rule/fn-max-params.js and 3 other locations - About 1 hr to fix
        lib/stylec/rule/fn-min-name.js on lines 7..19
        lib/stylec/rule/obj-key-max-len.js on lines 7..19
        lib/stylec/rule/obj-key-min-len.js on lines 7..19

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

        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 MaxLen = Rule.create({
          error: 'The object key is too long',
        
          option: {
            key: 'okeymax',
        Severity: Major
        Found in lib/stylec/rule/obj-key-max-len.js and 3 other locations - About 1 hr to fix
        lib/stylec/rule/fn-max-params.js on lines 7..19
        lib/stylec/rule/fn-min-name.js on lines 7..19
        lib/stylec/rule/obj-key-min-len.js on lines 7..19

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

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

        var MaxLen = Rule.create({
          error: 'The variable name is too long',
        
          option: {
            key: 'varmax',
        Severity: Major
        Found in lib/stylec/rule/var-max-len.js and 8 other locations - About 45 mins to fix
        lib/stylec/rule/increment-decrement.js on lines 7..18
        lib/stylec/rule/line-length.js on lines 7..18
        lib/stylec/rule/num-decimal.js on lines 7..18
        lib/stylec/rule/seq-whitespace.js on lines 7..18
        lib/stylec/rule/tabs.js on lines 7..18
        lib/stylec/rule/trailing-whitespace.js on lines 7..18
        lib/stylec/rule/unary.js on lines 7..18
        lib/stylec/rule/var-min-len.js on lines 7..18

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

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

        var Tabs = Rule.create({
          error: 'The line contains a tab',
        
          option: {
            key: 'notabs',
        Severity: Major
        Found in lib/stylec/rule/tabs.js and 8 other locations - About 45 mins to fix
        lib/stylec/rule/increment-decrement.js on lines 7..18
        lib/stylec/rule/line-length.js on lines 7..18
        lib/stylec/rule/num-decimal.js on lines 7..18
        lib/stylec/rule/seq-whitespace.js on lines 7..18
        lib/stylec/rule/trailing-whitespace.js on lines 7..18
        lib/stylec/rule/unary.js on lines 7..18
        lib/stylec/rule/var-max-len.js on lines 7..18
        lib/stylec/rule/var-min-len.js on lines 7..18

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

        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