yuku-t/hyperapp-apollo

View on GitHub

Showing 12 of 12 total issues

File Query.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Component, ActionsType, VNode } from "hyperapp"
import {
  ApolloQueryResult,
  ObservableQuery,
  ApolloClient,
Severity: Minor
Found in src/Query.ts - About 2 hrs to fix

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

      initQuery: (props: query.QueryProps<any, any>) => ({ client }, actions) => {
        actions.query.initializeQueryObservable({
          props,
          client: getClient(client)
        })
    Severity: Major
    Found in src/apollo.ts and 1 other location - About 1 hr to fix
    src/apollo.ts on lines 39..44

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

    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

      initMutation: (props: mutation.MutationProps<any, any>) => ({ client }, actions) => {
        actions.mutation.initialize({
          props,
          client: getClient(client)
        })
    Severity: Major
    Found in src/apollo.ts and 1 other location - About 1 hr to fix
    src/apollo.ts on lines 33..38

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

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

      startQuerySubscription: (key: string) => (_, actions) => {
        const local = locals[key]
        if (local.subscription) {
          return
        }
    Severity: Minor
    Found in src/Query.ts - 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

    Function Query has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function Query<Data, Variables>(props: QueryProps<Data, Variables>, children: any) {
      return (state: { apollo: apollo.State }, actions: { apollo: apollo.Actions }) => {
        if (!locals[props.key]) {
          actions.apollo.initQuery(props)
          return
    Severity: Minor
    Found in src/Query.ts - About 1 hr to fix

      Function Mutation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function Mutation<Data = any, Variables = OperationVariables>(
        props: MutationProps<Data, Variables>,
        children: any
      ) {
        return (state: { apollo: apollo.State }, actions: { apollo: apollo.Actions }) => {
      Severity: Minor
      Found in src/Mutation.ts - About 1 hr to fix

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

        function getRenderProps<Data, Variables>(
          props: MutationProps<Data, Variables>,
          state: MutationState<Data>,
          actions: Actions
        ): RenderProps<Data, Variables> {
        Severity: Minor
        Found in src/Mutation.ts - About 1 hr to fix

          Function willReceiveProps has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            willReceiveProps: (nextProps: QueryProps) => (_, actions) => {
              const key = nextProps.key
              const prevProps = locals[key].props!
              if (nextProps.skip && !prevProps.skip) {
                actions.removeQuerySubscription(key)
          Severity: Minor
          Found in src/Query.ts - About 55 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

            onMutationError: (params: { props: MutationProps<any, any>; error: ApolloError; mutationId: number }) => void
          Severity: Minor
          Found in src/Mutation.ts and 1 other location - About 40 mins to fix
          src/Mutation.ts on lines 78..78

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

          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

            onCompletedMutation: (params: { props: MutationProps<any, any>; response: FetchResult; mutationId: number }) => void
          Severity: Minor
          Found in src/Mutation.ts and 1 other location - About 40 mins to fix
          src/Mutation.ts on lines 79..79

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

          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

            initialize: (params: { props: MutationProps<any, any>; client: ApolloClient<any> }) => void
          Severity: Minor
          Found in src/Mutation.ts and 1 other location - About 30 mins to fix
          src/Query.ts on lines 87..87

          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

            initializeQueryObservable: (params: { props: QueryProps<any, any>; client: ApolloClient<any> }) => void
          Severity: Minor
          Found in src/Query.ts and 1 other location - About 30 mins to fix
          src/Mutation.ts on lines 75..75

          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