Showing 36 of 67 total issues

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

export function ofActionErrored<T extends ActionType[]>(
  ...allowedTypes: T
): OperatorFunction<
  ActionContext<Constructed<T[TupleKeys<T>]>>,
  ActionCompletion<Constructed<T[TupleKeys<T>]>>
Severity: Major
Found in packages/store/src/operators/of-action.ts and 1 other location - About 1 hr to fix
packages/store/src/operators/of-action.ts on lines 88..100

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

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

Consider simplifying this complex logical expression.
Open

    if (
      hasOwnProp.call(o, prop) &&
      (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
      o[prop] !== null &&
      (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
Severity: Critical
Found in packages/store/src/utils/freeze.ts - About 1 hr to fix

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

    export const NGXS_FEATURE_ENVIRONMENT_INITIALIZER: Provider[] = [
      { provide: NGXS_FEATURE_STORE_INITIALIZER, useFactory: featureStatesInitializer },
      {
        provide: ENVIRONMENT_INITIALIZER,
        multi: true,
    Severity: Major
    Found in packages/store/src/standalone-features/initializers.ts and 1 other location - About 1 hr to fix
    packages/store/src/standalone-features/initializers.ts on lines 91..100

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

    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

    export const NGXS_ROOT_ENVIRONMENT_INITIALIZER: Provider[] = [
      { provide: NGXS_ROOT_STORE_INITIALIZER, useFactory: rootStoreInitializer },
      {
        provide: ENVIRONMENT_INITIALIZER,
        multi: true,
    Severity: Major
    Found in packages/store/src/standalone-features/initializers.ts and 1 other location - About 1 hr to fix
    packages/store/src/standalone-features/initializers.ts on lines 108..117

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

    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

        this._actions$
          .pipe(ofActionDispatched(ConnectWebSocket), takeUntil(this._destroy$))
          .subscribe(({ payload }) => {
            this.connect(payload);
          });
    Severity: Major
    Found in packages/websocket-plugin/src/websocket-handler.ts and 1 other location - About 1 hr to fix
    packages/websocket-plugin/src/websocket-handler.ts on lines 57..61

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

    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

        this._actions$
          .pipe(ofActionDispatched(SendWebSocketMessage), takeUntil(this._destroy$))
          .subscribe(({ payload }) => {
            this.send(payload);
          });
    Severity: Major
    Found in packages/websocket-plugin/src/websocket-handler.ts and 1 other location - About 1 hr to fix
    packages/websocket-plugin/src/websocket-handler.ts on lines 45..49

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

    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

    export const LOCAL_STORAGE_ENGINE = new InjectionToken<StorageEngine | null>(
      NG_DEV_MODE ? 'LOCAL_STORAGE_ENGINE' : '',
      {
        providedIn: 'root',
        factory: () => (isPlatformBrowser(inject(PLATFORM_ID)) ? localStorage : null)
    Severity: Major
    Found in packages/storage-plugin/src/engines.ts and 1 other location - About 1 hr to fix
    packages/storage-plugin/src/engines.ts on lines 17..23

    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

    export const SESSION_STORAGE_ENGINE = new InjectionToken<StorageEngine | null>(
      NG_DEV_MODE ? 'SESSION_STORAGE_ENGINE' : '',
      {
        providedIn: 'root',
        factory: () => (isPlatformBrowser(inject(PLATFORM_ID)) ? sessionStorage : null)
    Severity: Major
    Found in packages/storage-plugin/src/engines.ts and 1 other location - About 1 hr to fix
    packages/storage-plugin/src/engines.ts on lines 9..15

    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

    Function invokeActions has 52 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      invokeActions(dispatched$: Observable<ActionContext>, action: any) {
        const type = getActionTypeFromInstance(action)!;
        const results = [];
    
        // Determines whether the dispatched action has been handled, this is assigned
    Severity: Major
    Found in packages/store/src/internal/state-factory.ts - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Confirmed

                        if (isObservable(value)) {
                          return value;
                        }
      Severity: Major
      Found in packages/store/src/internal/state-factory.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (actionMeta.options.cancelUncompleted) {
                        // todo: ofActionDispatched should be used with action class
                        result = result.pipe(
                          takeUntil(dispatched$.pipe(ofActionDispatched(action as any)))
                        );
        Severity: Major
        Found in packages/store/src/internal/state-factory.ts - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

                  if (storedValue !== 'undefined' && storedValue != null) {
                    try {
                      const newVal = this._options.deserialize!(storedValue);
                      storedValue = this._options.afterDeserialize!(newVal, key);
                    } catch {
          Severity: Major
          Found in packages/storage-plugin/src/storage.plugin.ts - About 40 mins to fix

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

            export class HmrInitAction {
              static get type() {
                // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
                return '@@HMR_INIT';
              }
            Severity: Minor
            Found in packages/hmr-plugin/src/actions/hmr-init.action.ts and 1 other location - About 30 mins to fix
            packages/hmr-plugin/src/actions/hmr-before-destroy.action.ts on lines 3..10

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

            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

              leave<T>(func: () => T): T {
                return this._executionStrategy.leave(func);
              }
            packages/store/src/execution/internal-ngxs-execution-strategy.ts on lines 11..13

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

            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

              enter<T>(func: () => T): T {
                return this._executionStrategy.enter(func);
              }
            packages/store/src/execution/internal-ngxs-execution-strategy.ts on lines 15..17

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

            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

            export class HmrBeforeDestroyAction {
              static get type() {
                // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
                return '@@HMR_BEFORE_DESTROY';
              }
            Severity: Minor
            Found in packages/hmr-plugin/src/actions/hmr-before-destroy.action.ts and 1 other location - About 30 mins to fix
            packages/hmr-plugin/src/actions/hmr-init.action.ts on lines 3..10

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

            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