appbaseio/mirage

View on GitHub
app/queryBlocks/singlequery/queries/geohashcell.query.ts

Summary

Maintainability
D
2 days
Test Coverage

Function ngOnInit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    ngOnInit() {
        this.options = JSON.parse(JSON.stringify(this.default_options));
        try {
            if(this.appliedQuery[this.current_query][this.fieldName]['lat']) {
                this.inputs.lat.value = this.appliedQuery[this.current_query][this.fieldName]['lat'];
Severity: Minor
Found in app/queryBlocks/singlequery/queries/geohashcell.query.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

Function ngOnChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    ngOnChanges() {
        if(this.selectedField != '') {
            if(this.selectedField !== this.fieldName) {
                this.fieldName = this.selectedField;
                this.getFormat();
Severity: Minor
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts - About 25 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

Identical blocks of code found in 7 locations. Consider refactoring.
Open

    ngOnChanges() {
        if(this.selectedField != '') {
            if(this.selectedField !== this.fieldName) {
                this.fieldName = this.selectedField;
                this.getFormat();
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 6 other locations - About 5 hrs to fix
app/queryBlocks/singlequery/queries/common.query.ts on lines 126..140
app/queryBlocks/singlequery/queries/geoboundingbox.query.ts on lines 159..173
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 150..164
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 162..176
app/queryBlocks/singlequery/queries/geopolygon.query.ts on lines 109..123
app/queryBlocks/singlequery/queries/geoshape.query.ts on lines 119..133

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

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

            for (let option in this.appliedQuery[this.current_query][this.fieldName]) {
                if (option != 'lat' && option != 'lon') {
                    var obj = {
                        name: option,
                        value: this.appliedQuery[this.current_query][this.fieldName][option]
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 2 other locations - About 3 hrs to fix
app/queryBlocks/singlequery/queries/geoboundingbox.query.ts on lines 145..153
app/queryBlocks/singlequery/queries/range.query.ts on lines 106..114

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

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

            if(this.appliedQuery[this.current_query][this.fieldName]['lon']) {
                this.inputs.lon.value = this.appliedQuery[this.current_query][this.fieldName]['lon'];
            }
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 9 other locations - About 1 hr to fix
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 127..129
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 130..132
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 133..135
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 138..140
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 141..143
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 144..146
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 147..149
app/queryBlocks/singlequery/queries/geohashcell.query.ts on lines 112..114
app/queryBlocks/singlequery/queries/geopolygon.query.ts on lines 92..94

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

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

            if(this.appliedQuery[this.current_query][this.fieldName]['lat']) {
                this.inputs.lat.value = this.appliedQuery[this.current_query][this.fieldName]['lat'];
            }
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 9 other locations - About 1 hr to fix
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 127..129
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 130..132
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 133..135
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 138..140
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 141..143
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 144..146
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 147..149
app/queryBlocks/singlequery/queries/geohashcell.query.ts on lines 115..117
app/queryBlocks/singlequery/queries/geopolygon.query.ts on lines 92..94

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

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

Identical blocks of code found in 8 locations. Consider refactoring.
Open

    getFormat() {
        if (this.queryName === this.current_query) {
            this.queryFormat = this.setFormat();
            this.getQueryFormat.emit(this.queryFormat);
        }
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 7 other locations - About 1 hr to fix
app/queryBlocks/singlequery/queries/geoboundingbox.query.ts on lines 175..180
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 166..171
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 178..183
app/queryBlocks/singlequery/queries/geopolygon.query.ts on lines 125..130
app/queryBlocks/singlequery/queries/geoshape.query.ts on lines 135..140
app/queryBlocks/singlequery/queries/span_first.query.ts on lines 137..142
app/queryBlocks/singlequery/queries/span_term.query.ts on lines 124..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 64.

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

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

        this.optionRows.forEach(function(singleRow: any) {
            queryFormat[this.queryName][singleRow.name] = singleRow.value;
        }.bind(this));
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 5 other locations - About 1 hr to fix
app/queryBlocks/singlequery/queries/geoboundingbox.query.ts on lines 197..199
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 182..184
app/queryBlocks/singlequery/queries/geodistancerange.query.ts on lines 196..198
app/queryBlocks/singlequery/queries/geopolygon.query.ts on lines 144..146
app/queryBlocks/singlequery/queries/missing.query.ts on lines 131..133

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

    public inputs: any = {
        lat: {
            placeholder: 'Latitude',
            value: ''
        },
Severity: Major
Found in app/queryBlocks/singlequery/queries/geohashcell.query.ts and 1 other location - About 1 hr to fix
app/queryBlocks/singlequery/queries/geodistance.query.ts on lines 108..121

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

Identifier 'obj' is never reassigned; use 'const' instead of 'var'.
Open

                    var obj = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Don't use 'Number' as a type. Avoid using the Number type. Did you mean number?
Open

    removeOption(index: Number) {

Rule: ban-types

Bans specific types from being used. Does not ban the corresponding runtime objects from being used.

Notes
  • TypeScript Only

Config

A list of ["regex", "optional explanation here"], which bans types that match regex

Examples
"ban-types": true,Object,Use {} instead.,String
Schema
{
  "type": "list",
  "listType": {
    "type": "array",
    "items": {
      "type": "string"
    },
    "minLength": 1,
    "maxLength": 2
  }
}

For more information see this page.

Identifier 'option' is never reassigned; use 'const' instead of 'let'.
Open

            for (let option in this.appliedQuery[this.current_query][this.fieldName]) {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

!= should be !==
Open

                if (option != 'lat' && option != 'lon') {

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

object access via string literals is disallowed
Open

                this.inputs.lon.value = this.appliedQuery[this.current_query][this.fieldName]['lon'];

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

        var singleOption = JSON.parse(JSON.stringify(this.singleOption));

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

Identifier 'queryFormat' is never reassigned; use 'const' instead of 'var'.
Open

        var queryFormat = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

!= should be !==
Open

        if(this.selectedQuery != '') {

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

object access via string literals is disallowed
Open

            if(this.appliedQuery[this.current_query][this.fieldName]['lat']) {

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

Don't bind this without arguments as a scope to a function. Use an arrow lambda instead.
Open

        this.options = this.default_options.filter(function(opt) {
            var flag = true;
            this.optionRows.forEach(function(row) {
                if(row.name === opt) {
                    flag = false;

Rule: unnecessary-bind

Prevents unnecessary and/or misleading scope bindings on functions.

Rationale

function expressions that are immediately bound to this are equivalent to () => arrow lambdas. Additionally, there's no use in binding a scope to an arrow lambda, as it already has one.

Notes
  • Requires Type Info

Config

Not configurable.

Examples
"unnecessary-bind": true

For more information see this page.

object access via string literals is disallowed
Open

                this.inputs.precision.value = this.appliedQuery[this.current_query]['precision'];

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

Don't bind this without arguments as a scope to a function. Use an arrow lambda instead.
Open

        setTimeout(function() {
            this.getFormat();
        }.bind(this), 300);

Rule: unnecessary-bind

Prevents unnecessary and/or misleading scope bindings on functions.

Rationale

function expressions that are immediately bound to this are equivalent to () => arrow lambdas. Additionally, there's no use in binding a scope to an arrow lambda, as it already has one.

Notes
  • Requires Type Info

Config

Not configurable.

Examples
"unnecessary-bind": true

For more information see this page.

Identifier 'singleOption' is never reassigned; use 'const' instead of 'var'.
Open

        var singleOption = JSON.parse(JSON.stringify(this.singleOption));

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

!= should be !==
Open

                if (option != 'lat' && option != 'lon') {

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

block is empty
Open

        } catch(e) {}

Rule: no-empty

Disallows empty blocks.

Blocks with a comment inside are not considered empty.

Rationale

Empty blocks are often indicators of missing code.

Config

If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

Examples
"no-empty": true
"no-empty": true,allow-empty-catch
"no-empty": true,allow-empty-functions
"no-empty": true,allow-empty-catch,allow-empty-functions
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "allow-empty-catch"
        ]
      },
      {
        "type": "string",
        "enum": [
          "allow-empty-functions"
        ]
      }
    ]
  }
}

For more information see this page.

object access via string literals is disallowed
Open

                this.inputs.lat.value = this.appliedQuery[this.current_query][this.fieldName]['lat'];

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

object access via string literals is disallowed
Open

            if(this.appliedQuery[this.current_query]['precision']) {

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

object access via string literals is disallowed
Open

            if(this.appliedQuery[this.current_query][this.fieldName]['lon']) {

Rule: no-string-literal

Forbids unnecessary string literal property access. Allows obj["prop-erty"] (can't be a regular property access). Disallows obj["property"] (should be obj.property).

Rationale

If --noImplicitAny is turned off, property access via a string literal will be 'any' if the property does not exist.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-literal": true

For more information see this page.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

        var queryFormat = {

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

non-arrow functions are forbidden
Open

            this.optionRows.forEach(function(row) {

Rule: only-arrow-functions

Disallows traditional (non-arrow) function expressions.

Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).

Rationale

Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.

Config

Two arguments may be optionally provided:

  • "allow-declarations" allows standalone function declarations.
  • "allow-named-functions" allows the expression function foo() {} but not function() {}.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-declarations",
      "allow-named-functions"
    ]
  },
  "minLength": 0,
  "maxLength": 1
}

For more information see this page.

!= should be !==
Open

        if(this.selectedField != '') {

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

                    var obj = {

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

            var flag = true;

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

" should be '
Open

import { Component, OnInit, OnChanges, Input, Output, EventEmitter } from "@angular/core";

Rule: quotemark

Enforces quote character for string literals.

Notes
  • Has Fix

Config

Five arguments may be optionally provided:

  • "single" enforces single quotes.
  • "double" enforces double quotes.
  • "backtick" enforces backticks.
  • "jsx-single" enforces single quotes for JSX attributes.
  • "jsx-double" enforces double quotes for JSX attributes.
  • "avoid-template" forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if "avoid-escape" is enabled and both single and double quotes are present in the string (the latter option takes precedence).
  • "avoid-escape" allows you to use the "other" quotemark in cases where escaping would normally be required. For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
Examples
"quotemark": true,single,avoid-escape,avoid-template
"quotemark": true,single,jsx-double
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "single",
      "double",
      "backtick",
      "jsx-single",
      "jsx-double",
      "avoid-escape",
      "avoid-template"
    ]
  },
  "minLength": 0,
  "maxLength": 5
}

For more information see this page.

Don't bind this without arguments as a scope to a function. Use an arrow lambda instead.
Open

        this.optionRows.forEach(function(singleRow: any) {
            queryFormat[this.queryName][singleRow.name] = singleRow.value;
        }.bind(this));

Rule: unnecessary-bind

Prevents unnecessary and/or misleading scope bindings on functions.

Rationale

function expressions that are immediately bound to this are equivalent to () => arrow lambdas. Additionally, there's no use in binding a scope to an arrow lambda, as it already has one.

Notes
  • Requires Type Info

Config

Not configurable.

Examples
"unnecessary-bind": true

For more information see this page.

There are no issues that match your filters.

Category
Status