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
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"
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) {
- Read upRead up
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"
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,
- Read upRead up
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"
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) {
FileSystem
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
export class FileSystem {
root: RootTree
readonly localOnly: boolean
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"
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> {
- Read upRead up
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,
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"
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
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> {
- Read upRead up
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"
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?
- Read upRead up
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> {
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"
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"
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)
- Read upRead up
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"