fission-suite/webnative

View on GitHub

Showing 85 of 237 total issues

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

      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

      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

          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

            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

              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

                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

                  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

                        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

                        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

                          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

                              Function validatePermissions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function validatePermissions(
                                { app, fs, raw }: Permissions,
                                username: string
                              ): boolean {
                                const prefix = dictionary.filesystemPrefix(username)
                              Severity: Minor
                              Found in src/ucan/internal.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