cellog/ion-router

View on GitHub

Showing 58 of 58 total issues

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

  return (store as unknown) as Store<
    S & IonRouterState,
    (typeof store extends Store<any, infer Act> ? Act : never) &
      IonRouterActions
  > &
Severity: Major
Found in src/storeEnhancer.ts and 1 other location - About 1 hr to fix
src/storeEnhancer.ts on lines 56..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 56.

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

  ;((store as unknown) as Store<
    S & IonRouterState,
    (typeof store extends Store<any, infer Act> ? Act : never) &
      IonRouterActions
  > &
Severity: Major
Found in src/storeEnhancer.ts and 1 other location - About 1 hr to fix
src/storeEnhancer.ts on lines 62..67

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

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 updateState has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function updateState<
  ReduxState extends selectors.FullStateWithRouter,
  Params extends { [key: string]: string },
  ParamsState extends { [key: string]: any },
  Action extends { type: string; [key: string]: any },
Severity: Minor
Found in src/helpers.ts - About 1 hr to fix

    Function exitRoute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const exitRoute = <
      ReduxState extends selectors.FullStateWithRouter,
      Params extends { [key: string]: string },
      ParamsState extends { [key: string]: any },
      Action extends { type: string; [key: string]: any },
    Severity: Minor
    Found in src/helpers.ts - About 1 hr to fix

      Function NullComponent has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        Loading: React.FC,
        Component: React.FC,
        ElseComponent: React.FC,
        Wrapper: React.FC<WrapperProps>,
        wrapperProps: WrapperProps,
      Severity: Major
      Found in src/NullComponent.tsx - About 50 mins to fix

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

              if (myRoutes.current.length) {
                dispatch(
                  actions.batchRemoveRoutes(
                    myRoutes.current as DeclareRoute<
                      FullStateWithRouter,
        Severity: Minor
        Found in src/Routes.tsx and 1 other location - About 50 mins to fix
        src/Routes.tsx on lines 58..64

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

        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

            if (myRoutes.current.length) {
              dispatch(
                actions.batchRoutes(
                  myRoutes.current as DeclareRoute<FullStateWithRouter, any, any, any>[]
                )
        Severity: Minor
        Found in src/Routes.tsx and 1 other location - About 50 mins to fix
        src/Routes.tsx on lines 66..77

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

        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 function goBack(): UrlAction<'goBack'> {
          return {
            type: types.ACTION,
            payload: {
              verb: 'goBack',
        Severity: Minor
        Found in src/actions.ts and 1 other location - About 35 mins to fix
        src/actions.ts on lines 123..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 47.

        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 function goForward(): UrlAction<'goForward'> {
          return {
            type: types.ACTION,
            payload: {
              verb: 'goForward',
        Severity: Minor
        Found in src/actions.ts and 1 other location - About 35 mins to fix
        src/actions.ts on lines 114..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 47.

        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 matchRoutesHelper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export const matchRoutesHelper: ActionHandler<actions.RouteAction> = (
          enhancedRoutes: enhancers.EnhancedRoutes,
          state: selectors.FullStateWithRouter,
          action: actions.RouteAction,
          updateParams: boolean = true
        Severity: Minor
        Found in src/helpers.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

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

        export function oldState(state: FullStateWithRouter, route: string) {
          return state.routing.routes.routes[route].state
        }
        Severity: Minor
        Found in src/selectors.ts and 1 other location - About 35 mins to fix
        src/selectors.ts on lines 31..33

        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

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

        export function oldParams(state: FullStateWithRouter, route: string) {
          return state.routing.routes.routes[route].params
        }
        Severity: Minor
        Found in src/selectors.ts and 1 other location - About 35 mins to fix
        src/selectors.ts on lines 27..29

        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

        Avoid too many return statements within this function.
        Open

                  return false
        Severity: Major
        Found in src/selectors.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return stateExists(state[key], template[key], full)
          Severity: Major
          Found in src/selectors.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return {
                    ...state,
                    routes: {
                      ids,
                      routes,
            Severity: Major
            Found in src/reducer.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return {
                      ...state,
                      routes: {
                        ids,
                        routes,
              Severity: Major
              Found in src/reducer.ts - About 30 mins to fix

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

                export function updateState<
                  ReduxState extends selectors.FullStateWithRouter,
                  Params extends { [key: string]: string },
                  ParamsState extends { [key: string]: any },
                  Action extends { type: string; [key: string]: any },
                Severity: Minor
                Found in src/helpers.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

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

                export function Route<
                  ReduxState extends FullStateWithRouter,
                  Params extends { [key: string]: string },
                  ParamsState extends { [key: string]: any },
                  Action extends { type: string; [key: string]: any }
                Severity: Minor
                Found in src/Route.tsx - 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

                Severity
                Category
                Status
                Source
                Language