fission-suite/webnative

View on GitHub

Showing 241 of 241 total issues

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.test.ts and 1 other location - About 2 hrs to fix
src/fs/protocol/private/namefilter.ts on lines 128..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 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

File path.node.test.ts has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import expect from "expect"
import * as fc from "fast-check"
import * as pathing from "./path.js"


Severity: Minor
Found in src/path.node.test.ts - About 2 hrs to fix

    PrivateTree has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class PrivateTree extends BaseTree {
    
      children: { [name: string]: PrivateTree | PrivateFile }
      header: PrivateTreeInfo
      history: PrivateHistory
    Severity: Minor
    Found in src/fs/v1/PrivateTree.ts - About 2 hrs to fix

      Function loadFileSystem has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function loadFileSystem(
        permissions: Maybe<Permissions>,
        username?: string,
        rootKey?: string
      ): Promise<FileSystem> {
      Severity: Minor
      Found in src/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 getClassifiedViaPostMessage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function getClassifiedViaPostMessage(): Promise<AuthLobbyClassifiedInfo> {
        const iframe: HTMLIFrameElement = await new Promise(resolve => {
          const iframe = document.createElement("iframe")
          iframe.id = "webnative-secret-exchange"
          iframe.style.width = "0"
      Severity: Major
      Found in src/auth/lobby.ts - About 2 hrs to fix

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

            try {
              message = uint8arrays.toString(
                await webcrypto.subtle.decrypt(
                  {
                    name: "AES-GCM",
        Severity: Major
        Found in src/auth/linking/producer.ts and 2 other locations - About 2 hrs to fix
        src/auth/linking/consumer.ts on lines 183..197
        src/auth/linking/consumer.ts on lines 288..302

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

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

        export const init = async (options: InitOptions): Promise<State | null> => {
          const permissions = options.permissions || null
          const { autoRemoveUrlParams = true, rootKey } = options
        
          // TODO: should be shared?
        Severity: Minor
        Found in src/auth/lobby.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

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

            try {
              encodedUcan = uint8arrays.toString(
                await webcrypto.subtle.decrypt(
                  {
                    name: "AES-GCM",
        Severity: Major
        Found in src/auth/linking/consumer.ts and 2 other locations - About 2 hrs to fix
        src/auth/linking/consumer.ts on lines 288..302
        src/auth/linking/producer.ts on lines 226..240

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

        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

            try {
              message = uint8arrays.toString(
                await webcrypto.subtle.decrypt(
                  {
                    name: "AES-GCM",
        Severity: Major
        Found in src/auth/linking/consumer.ts and 2 other locations - About 2 hrs to fix
        src/auth/linking/consumer.ts on lines 183..197
        src/auth/linking/producer.ts on lines 226..240

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

        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 initialise has 56 lines of code (exceeds 25 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: Major
        Found in src/index.ts - About 2 hrs to fix

          Function runOnNode has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

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

            export const isPrivateSkeleton = (obj: any): obj is PrivateSkeleton => {
              return isObject(obj)
                && Object.values(obj).every(a => isPrivateSkeletonInfo(a) || check.isSoftLink(a))
            }
            Severity: Major
            Found in src/fs/protocol/private/types/check.ts and 1 other location - About 2 hrs to fix
            src/fs/protocol/private/types/check.ts on lines 32..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 79.

            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 isPrivateLinks = (obj: any): obj is PrivateLinks => {
              return isObject(obj)
                && Object.values(obj).every(a => isPrivateLink(a) || check.isSoftLink(a))
            }
            Severity: Major
            Found in src/fs/protocol/private/types/check.ts and 1 other location - About 2 hrs to fix
            src/fs/protocol/private/types/check.ts on lines 37..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 79.

            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

              const u = await ucan.build({
                audience,
                issuer: await did.write(),
                lifetimeInSeconds: 60 * 60 * 24 * 30 * 12 * 1000, // 1000 years
                potency: "SUPER_USER",
            Severity: Major
            Found in src/auth/implementation/use-wnfs.ts and 1 other location - About 2 hrs to fix
            src/auth/implementation/base.ts on lines 62..71

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

            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

              const u = await ucan.build({
                audience,
                issuer: await did.write(),
                lifetimeInSeconds: 60 * 60 * 24 * 30 * 12 * 1000, // 1000 years
                potency: "SUPER_USER",
            Severity: Major
            Found in src/auth/implementation/base.ts and 1 other location - About 2 hrs to fix
            src/auth/implementation/use-wnfs.ts on lines 37..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 79.

            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 PublicTree.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { CID } from "multiformats/cid"
            
            import { FileContent } from "../../ipfs/index.js"
            import { Links, NonEmptyPath, SoftLink, Link, UpdateCallback } from "../types.js"
            import { Maybe } from "../../common/index.js"
            Severity: Minor
            Found in src/fs/v1/PublicTree.ts - About 2 hrs to fix

              Function handleSessionKey has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const handleSessionKey = async (temporaryRsaPrivateKey: CryptoKey, data: string): Promise<Result<CryptoKey, Error>> => {
                const typeGuard = (message: unknown): message is { iv: string; msg: string; sessionKey: 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 - About 2 hrs to fix

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

                export async function readKey({ path }: { path: DistinctivePath }): Promise<string> {
                  const hash = await crypto.hash.sha256Str(pathToString(path))
                  return `wnfs__readKey__${hash}`
                }
                Severity: Major
                Found in src/common/identifiers.ts and 1 other location - About 2 hrs to fix
                src/common/identifiers.ts on lines 7..10

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

                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 async function bareNameFilter({ path }: { path: DistinctivePath }): Promise<string> {
                  const hash = await crypto.hash.sha256Str(pathToString(path))
                  return `wnfs__bareNameFilter__${hash}`
                }
                Severity: Major
                Found in src/common/identifiers.ts and 1 other location - About 2 hrs to fix
                src/common/identifiers.ts on lines 12..15

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

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

                async function getClassifiedViaPostMessage(): Promise<AuthLobbyClassifiedInfo> {
                  const iframe: HTMLIFrameElement = await new Promise(resolve => {
                    const iframe = document.createElement("iframe")
                    iframe.id = "webnative-secret-exchange"
                    iframe.style.width = "0"
                Severity: Minor
                Found in src/auth/lobby.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

                Severity
                Category
                Status
                Source
                Language