cellog/ion-router

View on GitHub

Showing 58 of 58 total issues

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

expectType<BatchAddRoutesAction>(
  batchRoutes([
    {
      name: 'hi1',
      path: '/hi/:there',
Severity: Major
Found in src/type-tests/actions.test-d.ts and 1 other location - About 1 day to fix
src/type-tests/actions.test-d.ts on lines 163..194

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

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

expectType<BatchRemoveRoutesAction>(
  batchRemoveRoutes([
    {
      name: 'hi1',
      path: '/hi/:there',
Severity: Major
Found in src/type-tests/actions.test-d.ts and 1 other location - About 1 day to fix
src/type-tests/actions.test-d.ts on lines 129..160

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

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

expectError(
  addRoute({
    name: 'hi',
    path: '/hi/:there/:arr',
    parent: '',
Severity: Major
Found in src/type-tests/actions.test-d.ts and 1 other location - About 6 hrs to fix
src/type-tests/actions.test-d.ts on lines 30..58

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

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

export const createMiddleware = (
  history = createBrowserHistory(),
  handlers = actionHandlers,
  debug = false
) => {
Severity: Major
Found in src/middleware.ts - About 4 hrs to fix

    File helpers.ts has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { createPath, LocationDescriptorObject } from 'history'
    
    import * as actions from './actions'
    import * as selectors from './selectors'
    import * as enhancers from './enhancers'
    Severity: Minor
    Found in src/helpers.ts - About 3 hrs to fix

      File actions.test-d.ts has 310 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { expectType, expectError, expectAssignable } from 'tsd'
      
      import {
        addRoute,
        FullStateWithRouter,
      Severity: Minor
      Found in src/type-tests/actions.test-d.ts - About 3 hrs to fix

        File actions.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as types from './types'
        import { Location, History } from 'history'
        import { DeclareRoute } from './enhancers'
        import { FullStateWithRouter } from './selectors'
        
        
        Severity: Minor
        Found in src/actions.ts - About 3 hrs to fix

          Function Link has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export function Link<ExtraProps extends { [key: string]: any }>(
            props: Props & Partial<HTMLAnchor> & ExtraProps
          ) {
            const { to, replace, onClick, href, children, route, ...extra } = props
            const routeInfo = useContext(Context)
          Severity: Minor
          Found in src/Link.tsx - About 2 hrs 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 3 locations. Consider refactoring.
          Open

          export function getStateUpdates<
            ReduxState extends selectors.FullStateWithRouter,
            Params extends { [key: string]: string },
            ParamsState extends { [key: string]: any },
            Action extends { type: string; [key: string]: any },
          Severity: Major
          Found in src/helpers.ts and 2 other locations - About 2 hrs to fix
          src/helpers.ts on lines 108..141
          src/helpers.ts on lines 143..153

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

          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 3 locations. 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: Major
          Found in src/helpers.ts and 2 other locations - About 2 hrs to fix
          src/helpers.ts on lines 93..106
          src/helpers.ts on lines 143..153

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

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

          export function template<
            ReduxState extends selectors.FullStateWithRouter,
            Params extends { [key: string]: string },
            ParamsState extends { [key: string]: any },
            Action extends { type: string; [key: string]: any },
          Severity: Major
          Found in src/helpers.ts and 2 other locations - About 2 hrs to fix
          src/helpers.ts on lines 93..106
          src/helpers.ts on lines 108..141

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

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

          export function Link<ExtraProps extends { [key: string]: any }>(
            props: Props & Partial<HTMLAnchor> & ExtraProps
          ) {
            const { to, replace, onClick, href, children, route, ...extra } = props
            const routeInfo = useContext(Context)
          Severity: Major
          Found in src/Link.tsx - About 2 hrs to fix

            Function urlFromState has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function urlFromState(
              enhancedRoutes: enhancers.EnhancedRoutes,
              state: selectors.FullStateWithRouter
            ) {
              const toDispatch: actions.IonRouterActions[] = []
            Severity: Major
            Found in src/helpers.ts - About 2 hrs to fix

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

              export function batchRoutes<
                StoreState extends FullStateWithRouter,
                A extends '@@ion-router/BATCH_ROUTES'
              >(routes: DeclareRoute<StoreState, any, any, any>[]): BatchAddRoutesAction {
                return batch<StoreState, A>(
              Severity: Major
              Found in src/actions.ts and 1 other location - About 2 hrs to fix
              src/actions.ts on lines 253..261

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

              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 batchRemoveRoutes<
                StoreState extends FullStateWithRouter,
                A extends '@@ion-router/BATCH_REMOVE_ROUTES'
              >(routes: DeclareRoute<StoreState, any, any, any>[]): BatchRemoveRoutesAction {
                return batch<StoreState, A>(
              Severity: Major
              Found in src/actions.ts and 1 other location - About 2 hrs to fix
              src/actions.ts on lines 231..239

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

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

              export default function NullComponent<WrapperProps extends {}>(
                Loading: React.FC,
                Component: React.FC,
                ElseComponent: React.FC,
                Wrapper: React.FC<WrapperProps>,
              Severity: Minor
              Found in src/NullComponent.tsx - About 2 hrs 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 newStore has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const newStore = <S, A extends Action<any>>(
                  store: Store<S, A> & IonRouterOptions
                ) => {
                  assertEnhancedStore<S & FullStateWithRouter, A | actions.IonRouterActions>(
                    store
              Severity: Minor
              Found in src/middleware.ts - About 1 hr to fix

                Function NullComponent has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function NullComponent<WrapperProps extends {}>(
                  Loading: React.FC,
                  Component: React.FC,
                  ElseComponent: React.FC,
                  Wrapper: React.FC<WrapperProps>,
                Severity: Minor
                Found in src/NullComponent.tsx - About 1 hr to fix

                  Function Toggle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const Toggle = (props: NullComponentProps) => {
                      const rendered = useRef(0)
                      rendered.current++
                  
                      const {
                  Severity: Minor
                  Found in src/NullComponent.tsx - About 1 hr to fix

                    Function OuterToggle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export default function OuterToggle<
                      ExtraProps extends MightDefineVars,
                      StoreState extends FullStateWithRouter
                    >(
                      selector: ReduxSelector<StoreState>,
                    Severity: Minor
                    Found in src/Toggle.tsx - About 1 hr 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