TargetProcess/tauCharts

View on GitHub
src/elements/decorators/anchors.ts

Summary

Maintainability
A
2 hrs
Test Coverage

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

        getHighlightAttrs: function (node, model, filter) {
            const config = node.config;
            const guide = config.guide;
            const screenModel = node.screenModel;
            const showOnHover = node.config.guide.showAnchors === 'hover';
Severity: Minor
Found in src/elements/decorators/anchors.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 getHighlightAttrs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        getHighlightAttrs: function (node, model, filter) {
            const config = node.config;
            const guide = config.guide;
            const screenModel = node.screenModel;
            const showOnHover = node.config.guide.showAnchors === 'hover';
Severity: Minor
Found in src/elements/decorators/anchors.ts - About 35 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 2 locations. Consider refactoring.
Open

                    const path = getBrushLine([
                        {x, y, size: r},
                        {x: x0, y: y0, size: r}
                    ]);
Severity: Minor
Found in src/elements/decorators/anchors.ts and 1 other location - About 35 mins to fix
src/elements/decorators/anchors.ts on lines 127..130

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

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

                    const path = getBrushLine([
                        {x, y, size: r},
                        {x: x0, y: y0, size: r}
                    ]);
Severity: Minor
Found in src/elements/decorators/anchors.ts and 1 other location - About 35 mins to fix
src/elements/decorators/anchors.ts on lines 156..159

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

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

Expected method shorthand in object literal ('{getInitialAttrs() {...}}').
Open

        getInitialAttrs: function (node, model) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

Rule: object-literal-shorthand

Enforces/disallows use of ES6 object literal shorthand.

Notes
  • Has Fix

Config

"always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

Examples
"object-literal-shorthand": true
"object-literal-shorthand": true,never
"object-literal-shorthand": true,[object Object]
Schema
{
  "oneOf": [
    {
      "type": "string",
      "enum": [
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        "method": {
          "type": "string",
          "enum": [
            "never"
          ]
        }
      },
      "minProperties": 1,
      "maxProperties": 2
    }
  ]
}

For more information see this page.

Expected method shorthand in object literal ('{getInitialAttrs() {...}}').
Open

        getInitialAttrs: function (node, model) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

Rule: object-literal-shorthand

Enforces/disallows use of ES6 object literal shorthand.

Notes
  • Has Fix

Config

"always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

Examples
"object-literal-shorthand": true
"object-literal-shorthand": true,never
"object-literal-shorthand": true,[object Object]
Schema
{
  "oneOf": [
    {
      "type": "string",
      "enum": [
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        "method": {
          "type": "string",
          "enum": [
            "never"
          ]
        }
      },
      "minProperties": 1,
      "maxProperties": 2
    }
  ]
}

For more information see this page.

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

        getInitialAttrs: (node: GrammarElement, model: any) => Object;
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

non-arrow functions are forbidden
Open

        getHighlightAttrs: function (node, model, filter) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

non-arrow functions are forbidden
Open

        getInitialAttrs: function (node, model) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

non-arrow functions are forbidden
Open

        getHighlightAttrs: function (node, model, filter) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

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

        getHighlightAttrs: (node: GrammarElement, model: any, filter: (row) => boolean | null) => Object;
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

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

                        var r = screenModel.size(d) / 2;
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

Expected method shorthand in object literal ('{getHighlightAttrs() {...}}').
Open

        getHighlightAttrs: function (node, model, filter) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

Rule: object-literal-shorthand

Enforces/disallows use of ES6 object literal shorthand.

Notes
  • Has Fix

Config

"always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

Examples
"object-literal-shorthand": true
"object-literal-shorthand": true,never
"object-literal-shorthand": true,[object Object]
Schema
{
  "oneOf": [
    {
      "type": "string",
      "enum": [
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        "method": {
          "type": "string",
          "enum": [
            "never"
          ]
        }
      },
      "minProperties": 1,
      "maxProperties": 2
    }
  ]
}

For more information see this page.

Expected method shorthand in object literal ('{getHighlightAttrs() {...}}').
Open

        getHighlightAttrs: function (node, model, filter) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

Rule: object-literal-shorthand

Enforces/disallows use of ES6 object literal shorthand.

Notes
  • Has Fix

Config

"always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

Examples
"object-literal-shorthand": true
"object-literal-shorthand": true,never
"object-literal-shorthand": true,[object Object]
Schema
{
  "oneOf": [
    {
      "type": "string",
      "enum": [
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        "method": {
          "type": "string",
          "enum": [
            "never"
          ]
        }
      },
      "minProperties": 1,
      "maxProperties": 2
    }
  ]
}

For more information see this page.

non-arrow functions are forbidden
Open

        getInitialAttrs: function (node, model) {
Severity: Minor
Found in src/elements/decorators/anchors.ts by tslint

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.

There are no issues that match your filters.

Category
Status