yoctore/yoctopus-generator

View on GitHub
app/templates/applications/angular/_filter.js

Summary

Maintainability
B
6 hrs
Test Coverage

Irregular whitespace not allowed.
Open

      var dateFormat = format || "DD/MM/YYYY";

disallow irregular whitespace (no-irregular-whitespace)

Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code harder to debug in a similar nature to mixed tabs and spaces.

Various whitespace characters can be inputted by programmers by mistake for example from copying or keyboard shortcuts. Pressing Alt + Space on OS X adds in a non breaking space character for example.

Known issues these spaces cause:

  • Zero Width Space
    • Is NOT considered a separator for tokens and is often parsed as an Unexpected token ILLEGAL
    • Is NOT shown in modern browsers making code repository software expected to resolve the visualisation
  • Line Separator
    • Is NOT a valid character within JSON which would cause parse errors

Rule Details

This rule is aimed at catching invalid whitespace that is not a normal tab and space. Some of these characters may cause issues in modern browsers and others will be a debugging issue to spot.

This rule disallows the following characters except where the options allow:

\u000B - Line Tabulation (\v) - <vt>
\u000C - Form Feed (\f) - <ff>
\u00A0 - No-Break Space - <nbsp>
\u0085 - Next Line
\u1680 - Ogham Space Mark
\u180E - Mongolian Vowel Separator - <mvs>
\ufeff - Zero Width No-Break Space - <bom>
\u2000 - En Quad
\u2001 - Em Quad
\u2002 - En Space - <ensp>
\u2003 - Em Space - <emsp>
\u2004 - Tree-Per-Em
\u2005 - Four-Per-Em
\u2006 - Six-Per-Em
\u2007 - Figure Space
\u2008 - Punctuation Space - <puncsp>
\u2009 - Thin Space
\u200A - Hair Space
\u200B - Zero Width Space - <zwsp>
\u2028 - Line Separator
\u2029 - Paragraph Separator
\u202F - Narrow No-Break Space
\u205f - Medium Mathematical Space
\u3000 - Ideographic Space</zwsp></puncsp></emsp></ensp></bom></mvs></nbsp></ff></vt>

Options

This rule has an object option for exceptions:

  • "skipStrings": true (default) allows any whitespace characters in string literals
  • "skipComments": true allows any whitespace characters in comments
  • "skipRegExps": true allows any whitespace characters in regular expression literals
  • "skipTemplates": true allows any whitespace characters in template literals

skipStrings

Examples of incorrect code for this rule with the default { "skipStrings": true } option:

/*eslint no-irregular-whitespace: "error"*/

function thing() /*<nbsp>*/{
    return 'test';
}

function thing( /*<nbsp>*/){
    return 'test';
}

function thing /*<nbsp>*/(){
    return 'test';
}

function thing᠎/*<mvs>*/(){
    return 'test';
}

function thing() {
    return 'test'; /*<ensp>*/
}

function thing() {
    return 'test'; /*<nbsp>*/
}

function thing() {
    // Description <nbsp>: some descriptive text
}

/*
Description <nbsp>: some descriptive text
*/

function thing() {
    return / <nbsp>regexp/;
}

/*eslint-env es6*/
function thing() {
    return `template <nbsp>string`;
}</nbsp></nbsp></nbsp></nbsp></nbsp></ensp></mvs></nbsp></nbsp></nbsp>

Examples of correct code for this rule with the default { "skipStrings": true } option:

/*eslint no-irregular-whitespace: "error"*/

function thing() {
    return ' <nbsp>thing';
}

function thing() {
    return '​<zwsp>thing';
}

function thing() {
    return 'th <nbsp>ing';
}</nbsp></zwsp></nbsp>

skipComments

Examples of additional correct code for this rule with the { "skipComments": true } option:

/*eslint no-irregular-whitespace: ["error", { "skipComments": true }]*/

function thing() {
    // Description <nbsp>: some descriptive text
}

/*
Description <nbsp>: some descriptive text
*/</nbsp></nbsp>

skipRegExps

Examples of additional correct code for this rule with the { "skipRegExps": true } option:

/*eslint no-irregular-whitespace: ["error", { "skipRegExps": true }]*/

function thing() {
    return / <nbsp>regexp/;
}</nbsp>

skipTemplates

Examples of additional correct code for this rule with the { "skipTemplates": true } option:

/*eslint no-irregular-whitespace: ["error", { "skipTemplates": true }]*/
/*eslint-env es6*/

function thing() {
    return `template <nbsp>string`;
}</nbsp>

When Not To Use It

If you decide that you wish to use whitespace other than tabs and spaces outside of strings in your application.

Further Reading

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

angular.module('<%= name %>')
.filter('isArray', [ '_', function (_) {
  // default statement
  return function (value) {
    // default statement
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 8..15
app/templates/applications/angular/_filter.js on lines 22..29
app/templates/applications/angular/_filter.js on lines 141..148
app/templates/applications/angular/_filter.js on lines 183..190
app/templates/applications/angular/_filter.js on lines 197..204

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

angular.module('<%= name %>')
.filter('isObject', [ '_', function (_) {
  // default statement
  return function (value) {
    // default statement
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 8..15
app/templates/applications/angular/_filter.js on lines 22..29
app/templates/applications/angular/_filter.js on lines 141..148
app/templates/applications/angular/_filter.js on lines 169..176
app/templates/applications/angular/_filter.js on lines 197..204

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

angular.module('<%= name %>')
.filter('htmlsafe', [ '$sce', function ($sce) {
  // default statement
  return function (value) {
    // trust as html
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 22..29
app/templates/applications/angular/_filter.js on lines 141..148
app/templates/applications/angular/_filter.js on lines 169..176
app/templates/applications/angular/_filter.js on lines 183..190
app/templates/applications/angular/_filter.js on lines 197..204

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

angular.module('<%= name %>')
.filter('isEmpty', [ '_', function (_) {
  // default statement
  return function (value) {
    // default statement
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 8..15
app/templates/applications/angular/_filter.js on lines 22..29
app/templates/applications/angular/_filter.js on lines 141..148
app/templates/applications/angular/_filter.js on lines 169..176
app/templates/applications/angular/_filter.js on lines 183..190

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

angular.module('<%= name %>')
.filter('ucfirst', [ '_', function (_) {
  // default statement
  return function (value) {
    // return value
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 8..15
app/templates/applications/angular/_filter.js on lines 141..148
app/templates/applications/angular/_filter.js on lines 169..176
app/templates/applications/angular/_filter.js on lines 183..190
app/templates/applications/angular/_filter.js on lines 197..204

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

angular.module('<%= name %>')
.filter('isNumber', [ '_', function (_) {
  // default statement
  return function (value) {
    // default statement
Severity: Major
Found in app/templates/applications/angular/_filter.js and 5 other locations - About 1 hr to fix
app/templates/applications/angular/_filter.js on lines 8..15
app/templates/applications/angular/_filter.js on lines 22..29
app/templates/applications/angular/_filter.js on lines 169..176
app/templates/applications/angular/_filter.js on lines 183..190
app/templates/applications/angular/_filter.js on lines 197..204

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

There are no issues that match your filters.

Category
Status