Showing 98 of 283 total issues
Function constructor
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor({ account, dependencies, eventEmitter, root, localOnly }: ConstructorParams) {
this.account = account
this.dependencies = dependencies
this.eventEmitter = eventEmitter
Function empty
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async empty({ accountDID, dependencies, rootKey, wnfsWasm }: {
accountDID: string
dependencies: Dependencies
rootKey: Uint8Array
wnfsWasm?: boolean
Function getRecurse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
async getRecurse(skel: Skeleton, path: NonEmptyPath): Promise<SkeletonInfo | Child | null> {
const head = path[ 0 ]
const child = skel[ head ] || null
const nextPath = nextNonEmpty(path)
- 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 mv
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async mv(from: Path, to: Path): Promise<this> {
const node = await this.get(from)
if (node === null) {
throw new Error(`Path does not exist: ${Pathing.log(from)}`)
}
Function handleUserChallenge
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const handleUserChallenge = async (
crypto: Crypto.Implementation,
sessionKey: CryptoKey,
data: string
): Promise<Result<{ pin: number[]; audience: string }, Error>> => {
Function deleteByDomain
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function deleteByDomain(
endpoints: Fission.Endpoints,
dependencies: Dependencies,
domain: string
): Promise<void> {
Function runMutationOnNode
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async runMutationOnNode(
path: DistinctivePath<Partitioned<Partition>>,
handlers: {
public(root: UnixTree, relPath: Path.Segments): Promise<void>
private(node: PrivateTree | PrivateFile, relPath: Path.Segments): Promise<void>
Function ls
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async ls(path: Path): Promise<Links> {
const root = await this.root
const { result: node } = await this.withError(
root.getNode(path, this.store),
Function challengeOnce
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const challengeOnce = () => {
let called = false
return {
confirmPin: async () => {
Function sharePrivate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async sharePrivate(paths: Path.Distinctive<Path.PartitionedNonEmpty<Path.Private>>[], { sharedBy, shareWith }: { sharedBy?: SharedBy; shareWith: string | string[] }): Promise<ShareDetails> {
const verifiedPaths = paths.filter(path => {
return Path.isOnRootBranch(Path.RootBranch.Private, path)
})
Function private
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private: async (node, relPath) => {
if (FsTypeChecks.isFile(node)) {
throw new Error("Cannot add a soft link to a file")
}
Function generateSessionKey
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const generateSessionKey = async (
crypto: Crypto.Implementation,
didThrowaway: string
): Promise<{ sessionKey: CryptoKey; sessionKeyMessage: string }> => {
const sessionKey = await crypto.aes.genKey(Crypto.SymmAlg.AES_GCM)
Function update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function update(
endpoints: Fission.Endpoints,
dependencies: Dependencies,
cidInstance: CID,
proof: Ucan.Ucan
Function handleUserChallenge
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
export const handleUserChallenge = async (
crypto: Crypto.Implementation,
sessionKey: CryptoKey,
data: string
): Promise<Result<{ pin: number[]; audience: string }, Error>> => {
- 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 create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function create(repoName: string): IPFSRepo {
const memoryDs = new MemoryDatastore()
return createRepo(
repoName,
Function create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function create(
endpoints: Fission.Endpoints,
dependencies: Dependencies,
subdomain: Maybe<string>
): Promise<AppMetadata> {
Function getState
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function getState(config: Config): Promise<State> {
const { capabilities, dependencies, namespace, session } = config
const agentDID = await DID.agent(dependencies.crypto)
let accountDID = null
Function linkDevice
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function linkDevice(
dependencies: Dependencies,
username: string,
data: Record<string, unknown>
): Promise<void> {
Function mv
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async mv(from: Path.Distinctive<PartitionedNonEmpty<Partition>>, to: Path.Distinctive<PartitionedNonEmpty<Partition>>): Promise<this> {
const sameTree = Path.isSamePartition(from, to)
if (!Path.isSameKind(from, to)) {
const kindFrom = Path.kind(from)
Consider simplifying this complex logical expression. Open
Open
if (
typeof val === "object" &&
hasProp(val, "version") &&
hasProp(val, "code") && isNum(val.code) &&
hasProp(val, "hash") && isObject(val.hash) && Object.values(val.hash).every(isNum)