nigrosimone/ng-simple-state

View on GitHub

Showing 18 of 18 total issues

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

    selectState<K>(selectFn?: (state: Readonly<S>) => K, comparator?: (previous: K, current: K) => boolean): Signal<K> {
        if (!selectFn) {
            selectFn = (tmpState: Readonly<S>) => Object.assign(this.isArray ? [] : {}, tmpState) as K;
        }
        if (!comparator && this.comparator) {
projects/ng-simple-state/src/lib/ng-simple-state-common.ts on lines 93..93

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

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

    abstract selectState<K>(selectFn?: (state: Readonly<S>) => K, comparator?: (previous: K, current: K) => boolean): any;
Severity: Minor
Found in projects/ng-simple-state/src/lib/ng-simple-state-common.ts and 1 other location - About 45 mins to fix
projects/ng-simple-state/src/lib/signal/ng-simple-state-base-store.ts on lines 31..39

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

Missing semicolon
Open

            console.warn('NgSimpleStateBaseStore is deprecated. Please use NgSimpleStateBaseRxjsStore')

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

Type number trivially inferred from a number literal, remove type annotation
Open

    protected stackPoint: number = 6;

Rule: no-inferrable-types

Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.

Rationale

Explicit types where they can be easily inferred by the compiler make code more verbose.

Notes
  • TypeScript Only
  • Has Fix

Config

Two arguments may be optionally provided:

  • ignore-params allows specifying an inferrable type annotation for function params. This can be useful when combining with the typedef rule.
  • ignore-properties allows specifying an inferrable type annotation for class properties.
Examples
"no-inferrable-types": true
"no-inferrable-types": true,ignore-params
"no-inferrable-types": true,ignore-params,ignore-properties
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-params",
      "ignore-properties"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

Missing semicolon
Open

    override ngOnDestroy(): void {

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

The name of the class NgSimpleStateBaseRxjsStore should end with the suffix Directive (https://angular.io/styleguide#style-02-03)
Open

export abstract class NgSimpleStateBaseRxjsStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> implements OnDestroy {

Rule: directive-class-suffix

Classes decorated with @Directive must have suffix "Directive" (or custom) in their name.

See more at https://angular.io/styleguide#style-02-03.

Rationale

Consistent conventions make it easy to quickly identify and reference assets of different types.

Notes
  • TypeScript Only

Config

Supply a list of allowed component suffixes. Defaults to "Directive".

Examples
"directive-class-suffix": true
"directive-class-suffix": true,Directive,MySuffix
Schema
{
  "items": {
    "type": "string"
  },
  "minLength": 0,
  "type": "array"
}

For more information see this page.

trailing whitespace
Open

     * The store name 

Rule: no-trailing-whitespace

Disallows trailing whitespace at the end of a line.

Rationale

Keeps version control diffs clean as it prevents accidental whitespace from being committed.

Notes
  • Has Fix

Config

Possible settings are:

  • "ignore-template-strings": Allows trailing whitespace in template strings.
  • "ignore-comments": Allows trailing whitespace in comments.
  • "ignore-jsdoc": Allows trailing whitespace only in JSDoc comments.
  • "ignore-blank-lines": Allows trailing whitespace on empty lines.
Examples
"no-trailing-whitespace": true
"no-trailing-whitespace": true,ignore-comments
"no-trailing-whitespace": true,ignore-jsdoc
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-comments",
      "ignore-jsdoc",
      "ignore-template-strings",
      "ignore-blank-lines"
    ]
  }
}

For more information see this page.

The name of the class NgSimpleStateBaseStore should end with the suffix Directive (https://angular.io/styleguide#style-02-03)
Open

export abstract class NgSimpleStateBaseStore<S extends object | Array<any>> extends NgSimpleStateBaseRxjsStore<S> {

Rule: directive-class-suffix

Classes decorated with @Directive must have suffix "Directive" (or custom) in their name.

See more at https://angular.io/styleguide#style-02-03.

Rationale

Consistent conventions make it easy to quickly identify and reference assets of different types.

Notes
  • TypeScript Only

Config

Supply a list of allowed component suffixes. Defaults to "Directive".

Examples
"directive-class-suffix": true
"directive-class-suffix": true,Directive,MySuffix
Schema
{
  "items": {
    "type": "string"
  },
  "minLength": 0,
  "type": "array"
}

For more information see this page.

The name of the class NgSimpleStateBaseSignalStore should end with the suffix Directive (https://angular.io/styleguide#style-02-03)
Open

export abstract class NgSimpleStateBaseSignalStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> {

Rule: directive-class-suffix

Classes decorated with @Directive must have suffix "Directive" (or custom) in their name.

See more at https://angular.io/styleguide#style-02-03.

Rationale

Consistent conventions make it easy to quickly identify and reference assets of different types.

Notes
  • TypeScript Only

Config

Supply a list of allowed component suffixes. Defaults to "Directive".

Examples
"directive-class-suffix": true
"directive-class-suffix": true,Directive,MySuffix
Schema
{
  "items": {
    "type": "string"
  },
  "minLength": 0,
  "type": "array"
}

For more information see this page.

trailing whitespace
Open

     * A function used to compare the previous and current state for equality. 

Rule: no-trailing-whitespace

Disallows trailing whitespace at the end of a line.

Rationale

Keeps version control diffs clean as it prevents accidental whitespace from being committed.

Notes
  • Has Fix

Config

Possible settings are:

  • "ignore-template-strings": Allows trailing whitespace in template strings.
  • "ignore-comments": Allows trailing whitespace in comments.
  • "ignore-jsdoc": Allows trailing whitespace only in JSDoc comments.
  • "ignore-blank-lines": Allows trailing whitespace on empty lines.
Examples
"no-trailing-whitespace": true
"no-trailing-whitespace": true,ignore-comments
"no-trailing-whitespace": true,ignore-jsdoc
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-comments",
      "ignore-jsdoc",
      "ignore-template-strings",
      "ignore-blank-lines"
    ]
  }
}

For more information see this page.

Missing semicolon
Open

        super(injector)

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

trailing whitespace
Open

    /** 

Rule: no-trailing-whitespace

Disallows trailing whitespace at the end of a line.

Rationale

Keeps version control diffs clean as it prevents accidental whitespace from being committed.

Notes
  • Has Fix

Config

Possible settings are:

  • "ignore-template-strings": Allows trailing whitespace in template strings.
  • "ignore-comments": Allows trailing whitespace in comments.
  • "ignore-jsdoc": Allows trailing whitespace only in JSDoc comments.
  • "ignore-blank-lines": Allows trailing whitespace on empty lines.
Examples
"no-trailing-whitespace": true
"no-trailing-whitespace": true,ignore-comments
"no-trailing-whitespace": true,ignore-jsdoc
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-comments",
      "ignore-jsdoc",
      "ignore-template-strings",
      "ignore-blank-lines"
    ]
  }
}

For more information see this page.

file should end with a newline
Open

}

Rule: eofline

Ensures the file ends with a newline.

Fix for single-line files is not supported.

Rationale

It is a standard convention to end files with a newline.

Notes
  • Has Fix

Config

Not configurable.

Examples
"eofline": true

For more information see this page.

expected call-signature: 'statePersist' to have a typedef
Open

    protected statePersist(state: S) {

Rule: typedef

Requires type definitions to exist.

Notes
  • TypeScript Only

Config

Several arguments may be optionally provided:

  • "call-signature" checks return type of functions.
  • "arrow-call-signature" checks return type of arrow functions.
  • "parameter" checks type specifier of function parameters for non-arrow functions.
  • "arrow-parameter" checks type specifier of function parameters for arrow functions.
  • "property-declaration" checks return types of interface properties.
  • "variable-declaration" checks non-binding variable declarations.
  • "variable-declaration-ignore-function" ignore variable declarations for non-arrow and arrow functions.
  • "member-variable-declaration" checks member variable declarations.
  • "object-destructuring" checks object destructuring declarations.
  • "array-destructuring" checks array destructuring declarations.
Examples
"typedef": true,call-signature,parameter,member-variable-declaration
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "call-signature",
      "arrow-call-signature",
      "parameter",
      "arrow-parameter",
      "property-declaration",
      "variable-declaration",
      "variable-declaration-ignore-function",
      "member-variable-declaration",
      "object-destructuring",
      "array-destructuring"
    ]
  },
  "minLength": 0,
  "maxLength": 10
}

For more information see this page.

Type number trivially inferred from a number literal, remove type annotation
Open

    protected stackPoint: number = 3;

Rule: no-inferrable-types

Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.

Rationale

Explicit types where they can be easily inferred by the compiler make code more verbose.

Notes
  • TypeScript Only
  • Has Fix

Config

Two arguments may be optionally provided:

  • ignore-params allows specifying an inferrable type annotation for function params. This can be useful when combining with the typedef rule.
  • ignore-properties allows specifying an inferrable type annotation for class properties.
Examples
"no-inferrable-types": true
"no-inferrable-types": true,ignore-params
"no-inferrable-types": true,ignore-params,ignore-properties
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-params",
      "ignore-properties"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

Missing semicolon
Open

        })

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

file should end with a newline
Open

export * from './lib/ng-simple-state-common';

Rule: eofline

Ensures the file ends with a newline.

Fix for single-line files is not supported.

Rationale

It is a standard convention to end files with a newline.

Notes
  • Has Fix

Config

Not configurable.

Examples
"eofline": true

For more information see this page.

The name of the class NgSimpleStateBaseCommonStore should end with the suffix Directive (https://angular.io/styleguide#style-02-03)
Open

export abstract class NgSimpleStateBaseCommonStore<S extends object | Array<any>> implements OnDestroy {

Rule: directive-class-suffix

Classes decorated with @Directive must have suffix "Directive" (or custom) in their name.

See more at https://angular.io/styleguide#style-02-03.

Rationale

Consistent conventions make it easy to quickly identify and reference assets of different types.

Notes
  • TypeScript Only

Config

Supply a list of allowed component suffixes. Defaults to "Directive".

Examples
"directive-class-suffix": true
"directive-class-suffix": true,Directive,MySuffix
Schema
{
  "items": {
    "type": "string"
  },
  "minLength": 0,
  "type": "array"
}

For more information see this page.

Severity
Category
Status
Source
Language