fission-suite/webnative

View on GitHub

Showing 283 of 283 total issues

File PublicRootWasm.ts has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { CID } from "multiformats"
import { default as init, PublicDirectory, PublicFile, PublicNode } from "wnfs"

import * as Depot from "../../components/depot/implementation.js"
import * as Manners from "../../components/manners/implementation.js"
Severity: Minor
Found in src/fs/v3/PublicRootWasm.ts - About 4 hrs to fix

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

    export const createConsumer = async (
      dependencies: Dependencies,
      options: { username: string }
    ): Promise<AccountLinkingConsumer> => {
      const { username } = options
    Severity: Minor
    Found in src/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

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

      if (fs?.public) {
        const publ = fs.public.every(path => {
          const pathWithPrefix = `${prefix}public/` + Path.toPosix(path)
          const u = repo.getByKey(pathWithPrefix)
          ucan = u
    Severity: Major
    Found in src/capabilities.ts and 1 other location - About 3 hrs to fix
    src/capabilities.ts on lines 125..133

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

    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/` + Path.toPosix(path)
          const u = repo.getByKey(pathWithPrefix)
          ucan = u
    Severity: Major
    Found in src/capabilities.ts and 1 other location - About 3 hrs to fix
    src/capabilities.ts on lines 135..143

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

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

    export const createProducer = async (
      dependencies: Dependencies,
      options: { username: string }
    ): Promise<AccountLinkingProducer> => {
      const { username } = options
    Severity: Major
    Found in src/linking/producer.ts - About 3 hrs to fix

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

        async rm(path: Path): Promise<this> {
          this.checkMutability(`remove at ${[ ...this.directory, ...path ].join("/")}`)
          await this.publicRoot.rm([ ...this.directory, ...path ])
          await this.updateCache()
          return this
      Severity: Major
      Found in src/fs/v3/PublicRootWasm.ts and 1 other location - About 3 hrs to fix
      src/fs/v3/PublicRootWasm.ts on lines 318..323

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

      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 mkdir(path: Path): Promise<this> {
          this.checkMutability(`mkdir at ${[ ...this.directory, ...path ].join("/")}`)
          await this.publicRoot.mkdir([ ...this.directory, ...path ])
          await this.updateCache()
          return this
      Severity: Major
      Found in src/fs/v3/PublicRootWasm.ts and 1 other location - About 3 hrs to fix
      src/fs/v3/PublicRootWasm.ts on lines 336..341

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

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

        async write(
          path: Path.Distinctive<Partitioned<Partition>>,
          content: Uint8Array | SoftLink | SoftLink[] | Record<string, SoftLink>,
          options: MutationOptions = {}
        ): Promise<this> {
      Severity: Minor
      Found in src/fs/filesystem.ts - About 3 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

        it("generates a pin and challenge message", async () => {
          const { pin, challenge } = await Consumer.generateUserChallenge(crypto, sessionKey)
      
          expect(pin).toBeDefined()
          expect(pin).not.toBeNull()
      Severity: Major
      Found in src/linking/consumer.test.ts and 1 other location - About 3 hrs to fix
      src/linking/producer.test.ts on lines 19..26

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

      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("generates a session key and a session key message", async () => {
          const { sessionKey, sessionKeyMessage } = await producer.generateSessionKey(crypto, did)
      
          expect(sessionKey).toBeDefined()
          expect(sessionKey).not.toBeNull()
      Severity: Major
      Found in src/linking/producer.test.ts and 1 other location - About 3 hrs to fix
      src/linking/consumer.test.ts on lines 286..293

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

      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

        static async fromLatestName(
          crypto: Crypto.Implementation,
          depot: Depot.Implementation,
          mmpt: MMPT,
          name: PrivateName,
      Severity: Major
      Found in src/fs/v1/PrivateFile.ts and 1 other location - About 3 hrs to fix
      src/fs/v1/PrivateFile.ts on lines 134..143

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

      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

        static async fromName(
          crypto: Crypto.Implementation,
          depot: Depot.Implementation,
          mmpt: MMPT,
          name: PrivateName,
      Severity: Major
      Found in src/fs/v1/PrivateFile.ts and 1 other location - About 3 hrs to fix
      src/fs/v1/PrivateFile.ts on lines 123..132

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

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

      export const createConsumer = async (
        dependencies: Dependencies,
        options: { username: string }
      ): Promise<AccountLinkingConsumer> => {
        const { username } = options
      Severity: Major
      Found in src/linking/consumer.ts - About 3 hrs to fix

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

          const typeGuard = (message: unknown): message is { iv: string; msg: string } => {
            return Check.isObject(message)
              && "iv" in message && typeof message.iv === "string"
              && "msg" in message && typeof message.msg === "string"
          }
        Severity: Major
        Found in src/linking/consumer.ts and 1 other location - About 3 hrs to fix
        src/linking/producer.ts on lines 245..249

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

        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

          const typeGuard = (message: unknown): message is { iv: string; msg: string } => {
            return Check.isObject(message)
              && "iv" in message && typeof message.iv === "string"
              && "msg" in message && typeof message.msg === "string"
          }
        Severity: Major
        Found in src/linking/producer.ts and 1 other location - About 3 hrs to fix
        src/linking/consumer.ts on lines 315..319

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

        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

        const countOnes = (filter: BloomFilter): number => {
          const arr = new Uint32Array(filter.toBytes())
          let count = 0
          for (let i = 0; i < arr.length; i++) {
            count += bitCount32(arr[ i ])
        Severity: Major
        Found in src/fs/protocol/private/namefilter.ts and 1 other location - About 2 hrs to fix
        src/fs/protocol/private/namefilter.test.ts on lines 111..118

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

        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

        const countOnes = (filter: BloomFilter): number => {
          const arr = new Uint32Array(filter.toBytes())
          let count = 0
          for (let i = 0; i < arr.length; i++) {
            count += bitCount32(arr[ i ])
        Severity: Major
        Found in src/fs/protocol/private/namefilter.test.ts and 1 other location - About 2 hrs to fix
        src/fs/protocol/private/namefilter.ts on lines 109..116

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

        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

        FileSystem has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class FileSystem implements API {
        
          account: AssociatedIdentity
          dependencies: Dependencies
          eventEmitter: EventEmitter<Events.FileSystem>
        Severity: Minor
        Found in src/fs/filesystem.ts - About 2 hrs to fix

          File PublicTree.ts has 280 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { CID } from "multiformats/cid"
          
          import * as Common from "../../common/index.js"
          import * as Check from "../types/check.js"
          import * as Depot from "../../components/depot/implementation.js"
          Severity: Minor
          Found in src/fs/v1/PublicTree.ts - About 2 hrs to fix

            Function write has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async write(
                path: Path.Distinctive<Partitioned<Partition>>,
                content: Uint8Array | SoftLink | SoftLink[] | Record<string, SoftLink>,
                options: MutationOptions = {}
              ): Promise<this> {
            Severity: Major
            Found in src/fs/filesystem.ts - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language