XYOracleNetwork/sdk-xyo-client-js

View on GitHub

Showing 366 of 370 total issues

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

export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
try {
const url = new URL(urlToCheck)
let protocol = url.protocol
let host = url.host
packages/modules/packages/witness/packages/blockchain/packages/abstract/src/lib/checkIpfsUrl.ts on lines 11..43

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

export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
try {
const url = new URL(urlToCheck)
let protocol = url.protocol
let host = url.host
packages/modules/packages/witness/packages/evm/packages/abstract/src/lib/checkIpfsUrl.ts on lines 11..43

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

it.each(['asc', 'desc'] as const)('returns payloads without cursor [order: %s]', async (order) => {
const bound = order === 'asc' ? payloads.at(0) : payloads.at(-1)
expect(bound).toBeDefined()
const expected = order === 'asc' ? payloads.at(1) : payloads.at(-2)
expect(expected).toBeDefined()
packages/modules/packages/archivist/packages/acceptance-tests/src/query/next/next.ts on lines 26..45

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

it.each(['asc', 'desc'] as const)('returns payloads without cursor [order: %s]', async (order) => {
const bound = order === 'asc' ? payloads.at(0) : payloads.at(-1)
expect(bound).toBeDefined()
const expected = order === 'asc' ? payloads.at(1) : payloads.at(-2)
expect(expected).toBeDefined()
packages/modules/packages/archivist/packages/acceptance-tests/src/query/next/next.ts on lines 72..91

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

export const getProviderFromEnv = (
chainId: number = 0x01,
{ providerSource = 'infura', providerType = 'rpc' }: GetProvidersFromEnvOptions = {},
): Provider => {
let provider: Provider | undefined = undefined
packages/modules/packages/witness/packages/evm/packages/abstract/src/lib/getProviderFromEnv.ts on lines 34..80

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

export const getProviderFromEnv = (
chainId: number = 0x01,
{ providerSource = 'infura', providerType = 'rpc' }: GetProvidersFromEnvOptions = {},
): Provider => {
let provider: Provider | undefined = undefined
packages/modules/packages/witness/packages/blockchain/packages/abstract/src/lib/getProviderFromEnv.ts on lines 34..80

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

const levelDBArchivistSetup = async () => {
levelDbArchivist = await LevelDbArchivist.create({
account: 'random',
config: {
location: Path.join(process.cwd(), '.store', v4()),
packages/modules/packages/archivist/packages/benchmark-tests/src/spec/fileBackedArchivists.bench.ts on lines 48..64

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

const lmdbArchivistSetup = async () => {
lmdbArchivist = await LmdbArchivist.create({
account: 'random',
config: {
location: Path.join(process.cwd(), '.store', v4()),
packages/modules/packages/archivist/packages/benchmark-tests/src/spec/fileBackedArchivists.bench.ts on lines 26..42

Function resolveHandler has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

async resolveHandler<T extends ModuleInstance = ModuleInstance>(
id: ModuleIdentifier = '*',
options: ModuleFilterOptions<T> = {},
): Promise<T[]> {
const mutatedOptions = { ...options, maxDepth: options?.maxDepth ?? CompositeModuleResolver.defaultMaxDepth }

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

private async registerModule(wallet: WalletInstance, node: MemoryNode, manifest: ModuleManifest): Promise<ModuleInstance> {
const creatableModule = this.locator.locate(manifest.config.schema, manifest.config.labels)
const path = manifest.config.accountPath
const account = path ? await wallet.derivePath(path) : 'random'
const params: ModuleParams = {
Severity: Major
Found in packages/manifest/packages/wrapper/src/Wrapper.ts and 1 other location - About 1 day to fix
packages/manifest/packages/wrapper/src/WrapperEx.ts on lines 141..155

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

private async registerModule(wallet: WalletInstance, node: MemoryNode, manifest: ModuleManifest): Promise<ModuleInstance> {
const creatableModule = this.locator.locate(manifest.config.schema, manifest.config.labels)
const path = manifest.config.accountPath
const account = path ? await wallet.derivePath(path) : 'random'
const params: ModuleParams = {
Severity: Major
Found in packages/manifest/packages/wrapper/src/WrapperEx.ts and 1 other location - About 1 day to fix
packages/manifest/packages/wrapper/src/Wrapper.ts on lines 126..140

Function resolve has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

async resolve<T extends ModuleInstance = ModuleInstance>(
id: ModuleIdentifier = '*',
options?: ModuleFilterOptions<T>,
): Promise<T | T[] | undefined> {
// console.log(`childAddressMap: ${toJsonString(this.childAddressMap, 10)}`)

ModuleWrapper has 54 functions (exceeds 20 allowed). Consider refactoring.
Open

@constructableModuleWrapper()
export class ModuleWrapper<TWrappedModule extends Module = Module>
extends Base<Exclude<Omit<TWrappedModule['params'], 'config'> & { config: Exclude<TWrappedModule['params']['config'], undefined> }, undefined>>
implements AttachableModuleInstance<TWrappedModule['params'], TWrappedModule['eventData']> {
static readonly instanceIdentityCheck: InstanceTypeCheck = isModuleInstance

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

    export const attachedPublicModules = async (node: NodeInstance, maxDepth = 1): Promise<ModuleInstance[]> => {
    const remainingDepth = maxDepth - 1
    const mods: ModuleInstance[] = []
    const publicChildren = await node.publicChildren()
    mods.push(...publicChildren)
    packages/modules/packages/node/packages/abstract/src/NodeHelper/attachedPrivateModules.ts on lines 5..23

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

    export const attachedPrivateModules = async (node: NodeInstance, maxDepth = 1): Promise<ModuleInstance[]> => {
    const remainingDepth = maxDepth - 1
    const mods: ModuleInstance[] = []
    const publicChildren = await node.privateChildren()
    mods.push(...publicChildren)
    packages/modules/packages/node/packages/abstract/src/NodeHelper/attachedPublicModules.ts on lines 5..23

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

    protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
    const response = await this.monitorResponse<T>(async () => {
    return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)
    })
    return ApiBase.shapeResponse<T>(response, responseType)
    Severity: Major
    Found in packages/sdk-utils/packages/api/src/Base.ts and 1 other location - About 7 hrs to fix
    packages/sdk-utils/packages/api/src/Base.ts on lines 125..134

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

    protected async postEndpoint<T = unknown, D = unknown>(
    endPoint = '',
    data?: D,
    responseType?: ApiResponseType,
    ): Promise<ApiResponseTupleOrBody<T>> {
    Severity: Major
    Found in packages/sdk-utils/packages/api/src/Base.ts and 1 other location - About 7 hrs to fix
    packages/sdk-utils/packages/api/src/Base.ts on lines 139..144

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

    protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
    const response = await this.monitorResponse<T>(async () => {
    return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)
    })
    return ApiBase.shapeResponse<T>(response, responseType)
    Severity: Major
    Found in packages/sdk-utils/packages/api/src/Base.ts and 1 other location - About 6 hrs to fix
    packages/sdk-utils/packages/api/src/Base.ts on lines 73..78

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

    protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
    const response = await this.monitorResponse<T>(async () => {
    return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)
    })
    return ApiBase.shapeResponse<T>(response, responseType)
    Severity: Major
    Found in packages/sdk-utils/packages/api/src/Base.ts and 1 other location - About 6 hrs to fix
    packages/sdk-utils/packages/api/src/Base.ts on lines 83..88

    Function resolve has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    static async resolve<T extends ModuleInstance = ModuleInstance>(
    config: ResolveHelperConfig,
    id: ModuleIdentifier = '*',
    {
    maxDepth = 3, required = 'log', ...options
    Severity
    Category
    Status
    Source
    Language