GregBrimble/cf-workers-dashboard

View on GitHub

Showing 91 of 91 total issues

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

export const client = async (
  path: string,
  init: RequestInit = {},
  { complete }: { complete: boolean } = { complete: false }
) => {
Severity: Minor
Found in packages/server/src/pusher/client.ts and 1 other location - About 35 mins to fix
packages/server/src/graphql/cloudflare.ts on lines 7..24

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

  head(url: string, handler: Handler) {
    return this.handle(
      [MethodCondition(Method.Head), PathCondition(url)],
      handler
    );
Severity: Major
Found in packages/server/src/lib/router.ts and 8 other locations - About 35 mins to fix
packages/server/src/lib/router.ts on lines 40..45
packages/server/src/lib/router.ts on lines 47..52
packages/server/src/lib/router.ts on lines 54..59
packages/server/src/lib/router.ts on lines 68..73
packages/server/src/lib/router.ts on lines 75..80
packages/server/src/lib/router.ts on lines 82..87
packages/server/src/lib/router.ts on lines 89..94
packages/server/src/lib/router.ts on lines 96..101

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

  patch(url: string, handler: Handler) {
    return this.handle(
      [MethodCondition(Method.Patch), PathCondition(url)],
      handler
    );
Severity: Major
Found in packages/server/src/lib/router.ts and 8 other locations - About 35 mins to fix
packages/server/src/lib/router.ts on lines 40..45
packages/server/src/lib/router.ts on lines 47..52
packages/server/src/lib/router.ts on lines 54..59
packages/server/src/lib/router.ts on lines 61..66
packages/server/src/lib/router.ts on lines 68..73
packages/server/src/lib/router.ts on lines 82..87
packages/server/src/lib/router.ts on lines 89..94
packages/server/src/lib/router.ts on lines 96..101

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

  put(url: string, handler: Handler) {
    return this.handle(
      [MethodCondition(Method.Put), PathCondition(url)],
      handler
    );
Severity: Major
Found in packages/server/src/lib/router.ts and 8 other locations - About 35 mins to fix
packages/server/src/lib/router.ts on lines 40..45
packages/server/src/lib/router.ts on lines 47..52
packages/server/src/lib/router.ts on lines 54..59
packages/server/src/lib/router.ts on lines 61..66
packages/server/src/lib/router.ts on lines 68..73
packages/server/src/lib/router.ts on lines 75..80
packages/server/src/lib/router.ts on lines 82..87
packages/server/src/lib/router.ts on lines 96..101

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

  @ToOne({
    type: () => Script,
    key: "script",
    backRef: "_tailLogs",
    cascade: true,
Severity: Minor
Found in packages/server/src/models/TailLog.ts and 1 other location - About 35 mins to fix
packages/server/src/models/Script.ts on lines 40..46

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

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

export const makeRESTlient = (request: Request) => async (
  path: string,
  init: RequestInit = {},
  { complete }: { complete: boolean } = { complete: false }
) => {
Severity: Minor
Found in packages/server/src/graphql/cloudflare.ts and 1 other location - About 35 mins to fix
packages/server/src/pusher/client.ts on lines 8..37

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

  @ToOne({
    type: () => Account,
    key: "account",
    backRef: "_scripts",
    cascade: true,
Severity: Minor
Found in packages/server/src/models/Script.ts and 1 other location - About 35 mins to fix
packages/server/src/models/TailLog.ts on lines 30..36

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

}> = ({ state, dispatch, header = (accessor) => accessor }) => {
  const { data, isArray } = useMemo(() => {
    const { pathStack, data } = state;
    const path = last(pathStack);
    const currentData = path ? get(data, path) : data;
Severity: Minor
Found in packages/client/src/components/MagicTable/Table.tsx - 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

    sendTailHeartbeat: async (
      obj,
      {
        input: { accountID, scriptID, tailID },
      }: { input: SendTailHeartbeatInput },
Severity: Minor
Found in packages/server/src/graphql/schema/tail.ts and 1 other location - About 35 mins to fix
packages/server/src/graphql/schema/tail.ts on lines 67..91

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

    createTail: async (
      obj,
      { input: { accountID, scriptID, url } }: { input: CreateTailInput },
      context: Context
    ): Promise<Tail> => {
Severity: Minor
Found in packages/server/src/graphql/schema/tail.ts and 1 other location - About 35 mins to fix
packages/server/src/graphql/schema/tail.ts on lines 47..66

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 const Editor = () => {
  return (
    <BigStatus
      icon={<path d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />}
      text="Coming soon!"
Severity: Minor
Found in packages/client/src/components/workers/Editor.tsx and 1 other location - About 30 mins to fix
packages/client/src/components/workers/Peek.tsx on lines 132..139

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

      for (const field of value.fields) {
        objectValue[field.name.value] = getVariable(field.value, info);
      }
Severity: Minor
Found in packages/server/src/graphql/schema/analytics.ts and 1 other location - About 30 mins to fix
packages/server/src/graphql/schema/analytics.ts on lines 264..266

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 const Peek = () => {
  return (
    <BigStatus
      icon={<path d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />}
      text="Coming soon!"
Severity: Minor
Found in packages/client/src/components/workers/Peek.tsx and 1 other location - About 30 mins to fix
packages/client/src/components/workers/Editor.tsx on lines 4..11

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

Avoid too many return statements within this function.
Open

  return (
    <div>
      <a
        href="#"
        className={classNames(
Severity: Major
Found in packages/client/src/components/MagicTable/Cell.tsx - About 30 mins to fix

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

      for (const argument of fieldNode.arguments) {
        variables[argument.name.value] = getVariable(argument.value, info);
      }
    Severity: Minor
    Found in packages/server/src/graphql/schema/analytics.ts and 1 other location - About 30 mins to fix
    packages/server/src/graphql/schema/analytics.ts on lines 250..252

    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

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

    export const makeRESTlient = (request: Request) => async (
      path: string,
      init: RequestInit = {},
      { complete }: { complete: boolean } = { complete: false }
    ) => {
    Severity: Minor
    Found in packages/server/src/graphql/cloudflare.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

    First header should be a top level header
    Open

    ## Available Scripts
    Severity: Info
    Found in packages/client/README.md by markdownlint

    MD002 - First header should be a top level header

    Tags: headers

    Aliases: first-header-h1

    Parameters: level (number; default 1)

    This rule is triggered when the first header in the document isn't a h1 header:

    ## This isn't a H1 header
    
    ### Another header

    The first header in the document should be a h1 header:

    # Start with a H1 header
    
    ## Then use a H2 for subsections

    Spaces after list markers
    Open

        1.  Add KV Namespaces. For example:
    Severity: Info
    Found in packages/server/README.md by markdownlint

    MD030 - Spaces after list markers

    Tags: ol, ul, whitespace

    Aliases: list-marker-space

    Parameters: ulsingle, olsingle, ulmulti, olmulti (number, default 1)

    This rule checks for the number of spaces between a list marker (e.g. '-', '*', '+' or '1.') and the text of the list item.

    The number of spaces checked for depends on the document style in use, but the default is 1 space after any list marker:

    * Foo
    * Bar
    * Baz
    
    1. Foo
    1. Bar
    1. Baz
    
    1. Foo
       * Bar
    1. Baz

    A document style may change the number of spaces after unordered list items and ordered list items independently, as well as based on whether the content of every item in the list consists of a single paragraph, or multiple paragraphs (including sub-lists and code blocks).

    For example, the style guide at http://www.cirosantilli.com/markdown-styleguide/#spaces-after-marker specifies that 1 space after the list marker should be used if every item in the list fits within a single paragraph, but to use 2 or 3 spaces (for ordered and unordered lists respectively) if there are multiple paragraphs of content inside the list:

    * Foo
    * Bar
    * Baz
    
    vs.
    
    *   Foo
    
        Second paragraph
    
    *   Bar
    
    or
    
    1.  Foo
    
        Second paragraph
    
    1.  Bar

    To fix this, ensure the correct number of spaces are used after list marker for your selected document style.

    Spaces after list markers
    Open

    1.  Update `/src/types.d.ts`:
    Severity: Info
    Found in packages/server/README.md by markdownlint

    MD030 - Spaces after list markers

    Tags: ol, ul, whitespace

    Aliases: list-marker-space

    Parameters: ulsingle, olsingle, ulmulti, olmulti (number, default 1)

    This rule checks for the number of spaces between a list marker (e.g. '-', '*', '+' or '1.') and the text of the list item.

    The number of spaces checked for depends on the document style in use, but the default is 1 space after any list marker:

    * Foo
    * Bar
    * Baz
    
    1. Foo
    1. Bar
    1. Baz
    
    1. Foo
       * Bar
    1. Baz

    A document style may change the number of spaces after unordered list items and ordered list items independently, as well as based on whether the content of every item in the list consists of a single paragraph, or multiple paragraphs (including sub-lists and code blocks).

    For example, the style guide at http://www.cirosantilli.com/markdown-styleguide/#spaces-after-marker specifies that 1 space after the list marker should be used if every item in the list fits within a single paragraph, but to use 2 or 3 spaces (for ordered and unordered lists respectively) if there are multiple paragraphs of content inside the list:

    * Foo
    * Bar
    * Baz
    
    vs.
    
    *   Foo
    
        Second paragraph
    
    *   Bar
    
    or
    
    1.  Foo
    
        Second paragraph
    
    1.  Bar

    To fix this, ensure the correct number of spaces are used after list marker for your selected document style.

    Code block style
    Open

            ```typescript
    Severity: Info
    Found in packages/server/README.md by markdownlint
    Severity
    Category
    Status
    Source
    Language