fission-suite/webnative

View on GitHub

Showing 241 of 241 total issues

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

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(DID)

    expect(sessionKey).toBeDefined()
    expect(sessionKey).not.toBeNull()
Severity: Major
Found in src/auth/linking/producer.test.ts and 1 other location - About 3 hrs to fix
src/auth/linking/consumer.test.ts on lines 274..281

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

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 pin and challenge message", async () => {
    const { pin, challenge } = await consumer.generateUserChallenge(sessionKey)

    expect(pin).toBeDefined()
    expect(pin).not.toBeNull()
Severity: Major
Found in src/auth/linking/consumer.test.ts and 1 other location - About 3 hrs to fix
src/auth/linking/producer.test.ts on lines 22..29

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

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 82 lines of code (exceeds 25 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: Major
Found in src/auth/linking/producer.ts - About 3 hrs to fix

    Function initialise has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function initialise(options: InitOptions): Promise<State> {
      options = options || {}
    
      const permissions = options.permissions || null
      const { useWnfs = false, rootKey } = options
    Severity: Minor
    Found in src/index.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

      decrypt: async (encrypted: Uint8Array, keyStr: string, alg: SymmAlg): Promise<Uint8Array> => {
        const key = await importKey(keyStr, { length: SymmKeyLength.B256, alg })
        const decryptedBuf = await decryptBytes(encrypted, key, { alg })
        return new Uint8Array(decryptedBuf)
      },
    Severity: Major
    Found in src/crypto/index.ts and 1 other location - About 3 hrs to fix
    src/crypto/index.ts on lines 31..35

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

    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

      encrypt: async (data: Uint8Array, keyStr: string, alg: SymmAlg): Promise<Uint8Array> => {
        const key = await importKey(keyStr, { length: SymmKeyLength.B256, alg })
        const encrypted = await encryptBytes(data, key, { alg })
        return new Uint8Array(encrypted)
      },
    Severity: Major
    Found in src/crypto/index.ts and 1 other location - About 3 hrs to fix
    src/crypto/index.ts on lines 36..40

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

    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/auth/linking/consumer.ts and 1 other location - About 3 hrs to fix
    src/auth/linking/producer.ts on lines 213..217

    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/auth/linking/producer.ts and 1 other location - About 3 hrs to fix
    src/auth/linking/consumer.ts on lines 275..279

    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

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

    export class FileSystem {
    
      root: RootTree
      readonly localOnly: boolean
    
    
    Severity: Minor
    Found in src/fs/filesystem.ts - About 3 hrs to fix

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

      function isLobbyLinkingData(data: unknown): data is { readKey: string; ucan: string } {
        return check.isObject(data)
          && "readKey" in data && typeof data.readKey === "string"
          && "ucan" in data && typeof data.ucan === "string"
      }
      Severity: Major
      Found in src/auth/lobby.ts and 1 other location - About 2 hrs to fix
      src/auth/implementation/use-wnfs.ts on lines 51..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 93.

      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

      function isUseWnfsLinkingData(data: unknown): data is { readKey: string; ucan: string } {
        return check.isObject(data)
          && "readKey" in data && typeof data.readKey === "string"
          && "ucan" in data && typeof data.ucan === "string"
      }
      Severity: Major
      Found in src/auth/implementation/use-wnfs.ts and 1 other location - About 2 hrs to fix
      src/auth/lobby.ts on lines 151..155

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

      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 110..117

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

      File PrivateTree.ts has 285 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { CID } from "multiformats/cid"
      
      import BaseTree from "../base/tree.js"
      import MMPT from "../protocol/private/mmpt.js"
      import PrivateFile from "./PrivateFile.js"
      Severity: Minor
      Found in src/fs/v1/PrivateTree.ts - About 2 hrs to fix

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

        async function aesDecrypt(cipher: string, key: CryptoKey, ivStr: string): Promise<string> {
          return uint8arrays.toString(
            await webcrypto.subtle.decrypt(
              {
                name: "AES-GCM",
        Severity: Major
        Found in src/auth/linking/consumer.test.ts and 1 other location - About 2 hrs to fix
        src/auth/linking/producer.test.ts on lines 285..297

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

        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 function aesDecrypt(cipher: string, key: CryptoKey, ivStr: string): Promise<string> {
          return uint8arrays.toString(
            await webcrypto.subtle.decrypt(
              {
                name: "AES-GCM",
        Severity: Major
        Found in src/auth/linking/producer.test.ts and 1 other location - About 2 hrs to fix
        src/auth/linking/consumer.test.ts on lines 437..449

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

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

          async runOnNode<a>(
            path: DistinctivePath,
            isMutation: boolean,
            fn: (node: Tree | File, relPath: Path) => Promise<a>
          ): Promise<a> {
        Severity: Minor
        Found in src/fs/filesystem.ts - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function createConsumer has 68 lines of code (exceeds 25 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: Major
        Found in src/auth/linking/consumer.ts - About 2 hrs to fix

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

          const bitCount32 = (num: number): number => {
            const a = num - ((num >> 1) & 0x55555555)
            const b = (a & 0x33333333) + ((a >> 2) & 0x33333333)
            return ((b + (b >> 4) & 0xF0F0F0F) * 0x1010101) >> 24
          }
          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 121..125

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

          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