fission-suite/webnative

View on GitHub

Showing 241 of 241 total issues

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

describe("is string", () => {
  fc.assert(
    fc.property(fc.string(), data => {
      expect(check.isString(data)).toEqual(true)
    })
Severity: Major
Found in src/common/type-check.node.test.ts and 1 other location - About 1 day to fix
src/common/type-check.node.test.ts on lines 236..268

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

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

describe("is object", () => {
  fc.assert(
    fc.property(fc.object(), data => {
      expect(check.isObject(data)).toEqual(true)
    })
Severity: Major
Found in src/common/type-check.node.test.ts and 1 other location - About 1 day to fix
src/common/type-check.node.test.ts on lines 202..234

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

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

describe("not null", () => {
  fc.assert(
    fc.property(fc.frequency(
      { arbitrary: fc.object(), weight: 10 },
      { arbitrary: fc.string(), weight: 5 },
Severity: Major
Found in src/common/type-check.node.test.ts and 2 other locations - About 1 day to fix
src/common/type-check.node.test.ts on lines 65..92
src/common/type-check.node.test.ts on lines 94..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 289.

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

describe("is value", () => {
  fc.assert(
    fc.property(fc.frequency(
      { arbitrary: fc.object(), weight: 10 },
      { arbitrary: fc.string(), weight: 5 },
Severity: Major
Found in src/common/type-check.node.test.ts and 2 other locations - About 1 day to fix
src/common/type-check.node.test.ts on lines 36..63
src/common/type-check.node.test.ts on lines 65..92

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

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

describe("is just", () => {
  fc.assert(
    fc.property(fc.frequency(
      { arbitrary: fc.object(), weight: 10 },
      { arbitrary: fc.string(), weight: 5 },
Severity: Major
Found in src/common/type-check.node.test.ts and 2 other locations - About 1 day to fix
src/common/type-check.node.test.ts on lines 36..63
src/common/type-check.node.test.ts on lines 94..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 289.

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

File blocklist.ts has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Blocklist for usernames.
 *
 * Keep in sync with the Fission API.
 * https://github.com/fission-suite/fission/blob/master/library/Fission/User/Username/Validation.hs
Severity: Major
Found in src/lobby/blocklist.ts - About 1 day to fix

    File filesystem.ts has 509 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as cbor from "@ipld/dag-cbor"
    import * as uint8arrays from "uint8arrays"
    import { CID } from "multiformats/cid"
    import { SymmAlg } from "keystore-idb/lib/types.js"
    import { throttle } from "throttle-debounce"
    Severity: Major
    Found in src/fs/filesystem.ts - About 1 day to fix

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

      export const checkCapability = async (username: string): Promise<boolean> => {
        const readKey = await storage.getItem("readKey")
        if (!readKey) return false
      
        const didFromDNS = await did.root(username)
      Severity: Major
      Found in src/auth/implementation/use-wnfs.ts and 1 other location - About 7 hrs to fix
      src/auth/lobby.ts on lines 113..131

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

      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 checkCapability = async (username: string): Promise<boolean> => {
        const readKey = await storage.getItem("readKey")
        if (!readKey) return false
      
        const didFromDNS = await did.root(username)
      Severity: Major
      Found in src/auth/lobby.ts and 1 other location - About 7 hrs to fix
      src/auth/implementation/use-wnfs.ts on lines 12..30

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

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

      export const createProducer = async (options: { username: string }): Promise<AccountLinkingProducer> => {
        const { username } = options
        const canDelegate = await auth.checkCapability(username)
      
        if (!canDelegate) {
      Severity: Minor
      Found in src/auth/linking/producer.ts - About 7 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

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

        async createOrUpdateChildFile(content: FileContent, name: string, onUpdate: Maybe<UpdateCallback>): Promise<BareFile> {
          const existing = await this.getDirectChild(name)
          let file: BareFile
          if (existing === null) {
            file = await BareFile.create(content)
      Severity: Major
      Found in src/fs/bare/tree.ts and 1 other location - About 6 hrs to fix
      src/fs/v1/PublicTree.ts on lines 108..120

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

      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

        async createOrUpdateChildFile(content: FileContent, name: string, onUpdate: Maybe<UpdateCallback>): Promise<PublicFile> {
          const existing = await this.getDirectChild(name)
          let file: PublicFile
          if(existing === null){
            file = await PublicFile.create(content)
      Severity: Major
      Found in src/fs/v1/PublicTree.ts and 1 other location - About 6 hrs to fix
      src/fs/bare/tree.ts on lines 58..70

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

      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

      File consumer.test.ts has 370 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import expect from "expect"
      import * as uint8arrays from "uint8arrays"
      import { webcrypto } from "one-webcrypto"
      import aes from "keystore-idb/lib/aes/index.js"
      import config from "keystore-idb/lib/config.js"
      Severity: Minor
      Found in src/auth/linking/consumer.test.ts - About 4 hrs to fix

        Function createConsumer has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

        export const createConsumer = async (options: { username: string }): Promise<AccountLinkingConsumer> => {
          const { username } = options
          let eventEmitter: Maybe<EventEmitter<ConsumerEventMap>> = new EventEmitter()
          const ls: LinkingState = {
            username,
        Severity: Minor
        Found in src/auth/linking/consumer.ts - About 4 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

        File tree.ts has 341 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as cbor from "@ipld/dag-cbor"
        import * as uint8arrays from "uint8arrays"
        import { CID } from "multiformats/cid"
        
        import { AddResult } from "../../ipfs/index.js"
        Severity: Minor
        Found in src/fs/root/tree.ts - About 4 hrs to fix

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

          async function aesEncrypt(payload: string, key: CryptoKey, ivStr: string | ArrayBuffer): Promise<string> {
            const iv = typeof ivStr === "string" ? uint8arrays.fromString(ivStr, "base64") : ivStr
            return utils.arrBufToBase64(
              await webcrypto.subtle.encrypt(
                { name: "AES-GCM", iv },
          Severity: Major
          Found in src/auth/linking/consumer.test.ts and 1 other location - About 4 hrs to fix
          src/auth/linking/producer.test.ts on lines 274..283

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

          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

          async function aesEncrypt(payload: string, key: CryptoKey, ivStr: string | ArrayBuffer): Promise<string> {
            const iv = typeof ivStr === "string" ? uint8arrays.fromString(ivStr, "base64") : ivStr
            return utils.arrBufToBase64(
              await webcrypto.subtle.encrypt(
                { name: "AES-GCM", iv },
          Severity: Major
          Found in src/auth/linking/producer.test.ts and 1 other location - About 4 hrs to fix
          src/auth/linking/consumer.test.ts on lines 426..435

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

          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 (fs?.public) {
              const publ = fs.public.every(path => {
                const pathWithPrefix = `${prefix}public/` + pathing.toPosix(path)
                const u = dictionary.lookup(pathWithPrefix)
                return u && !token.isExpired(token.decode(u))
          Severity: Major
          Found in src/ucan/internal.ts and 1 other location - About 3 hrs to fix
          src/ucan/internal.ts on lines 48..55

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

          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 (fs?.private) {
              const priv = fs.private.every(path => {
                const pathWithPrefix = `${prefix}private/` + pathing.toPosix(path)
                const u = dictionary.lookup(pathWithPrefix)
                return u && !token.isExpired(token.decode(u))
          Severity: Major
          Found in src/ucan/internal.ts and 1 other location - About 3 hrs to fix
          src/ucan/internal.ts on lines 57..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 113.

          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

            it("creates file paths", () => {
              fc.assert(
                fc.property(fc.array(fc.hexaString()), data => {
                  expect(pathing.file(...data)).toEqual({
                    file: data
          Severity: Major
          Found in src/path.node.test.ts and 1 other location - About 3 hrs to fix
          src/path.node.test.ts on lines 13..25

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

          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