Showing 21 of 393 total issues
File types-lookup.ts
has 2579 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
// import type lookup before we augment - in some environments
// this is required to allow for ambient/previous definitions
File lookup.ts
has 2107 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
/* eslint-disable sort-keys */
File augment-types.ts
has 1212 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
// import type lookup before we augment - in some environments
// this is required to allow for ambient/previous definitions
SubsocialSubstrateApi
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
export class SubsocialSubstrateApi {
private _api: SubstrateApi // Polkadot API (connected)
constructor ({ api }: SubstrateApiProps) {
Function loadRelatedStructs
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function loadRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts) {
const { withSpace, withOwner } = opts || {}
const { findSpaces, findPosts, findProfileSpaces } = finders
const ownerByIdMap = new Map<string, RawSpaceData>()
SubsocialApi
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
export class SubsocialApi implements ISubsocialApi {
private readonly _base: BasicSubsocialApi
constructor (props: SubsocialApiProps) {
this._base = new BasicSubsocialApi(props)
Function loadRelatedStructs
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
async function loadRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts) {
const { withSpace, withOwner } = opts || {}
const { findSpaces, findPosts, findProfileSpaces } = finders
const ownerByIdMap = new Map<string, RawSpaceData>()
- 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
BasicSubsocialApi
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export class BasicSubsocialApi extends InnerSubsocialApi {
private structFinders: FindStructsFns = {
findSpaces: this.findPublicSpaces.bind(this),
findPosts: this.findPublicPosts.bind(this),
File index.ts
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { ApiPromise as SubstrateApi } from '@polkadot/api';
import { bool, GenericAccountId, Tuple } from '@polkadot/types';
import { Space, SpaceId, Post, PostId, Reaction, ReactionId, RoleId, User } from '../types/substrate';
import { getFirstOrUndefined, idToBn, isEmptyArray, newLogger, pluralize } from '@subsocial/utils';
import { asAccountId, getUniqueIds, SupportedSubstrateId, SupportedSubstrateResult } from '../utils';
Function onDocumentPointerUp
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
onDocumentPointerUp(e: Event) {
if (hasPointerMoved) return;
if (this.active) {
if ((e.target as HTMLElement).closest(".col-menu")) {
const link = (e.target as HTMLElement).closest("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 loadAndSetPostRelatedStructs
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export async function loadAndSetPostRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts): Promise<RawPostWithSomeDetails[]> {
const { withSpace, withOwner, visibility } = opts || {}
const {
spaceByIdMap,
ownerByIdMap,
- 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 initSearch
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function initSearch() {
const searchEl = document.getElementById("tsd-search");
if (!searchEl) return;
const searchScript = document.getElementById(
Function loadAndSetPostRelatedStructs
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function loadAndSetPostRelatedStructs (posts: RawPostData[], finders: FindStructsFns, opts?: PostDetailsOpts): Promise<RawPostWithSomeDetails[]> {
const { withSpace, withOwner, visibility } = opts || {}
const {
spaceByIdMap,
ownerByIdMap,
Function pluralize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function pluralize ({ count, singularText, pluralText, hideCount }: Props) {
if (!count) {
count = ZERO;
} else if (typeof count === 'string') {
- 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 bindEvents
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bindEvents(
searchEl: HTMLElement,
results: HTMLElement,
field: HTMLInputElement,
state: SearchState
Function findStructs
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async findStructs<T extends SupportedSubstrateResult>
(storageItem: StorageItem, ids: SupportedSubstrateId[]): Promise<T[]> {
const storage = storageItem.storage
try {
Function setCurrentResult
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function setCurrentResult(results: HTMLElement, dir: number) {
let current = results.querySelector(".current");
if (!current) {
current = results.querySelector(
dir == 1 ? "li:first-child" : "li:last-child"
- 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 initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected initialize() {
document.documentElement.classList.add(
"toggle-" + this.key + this.value
);
Function onScroll
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private onScroll(event: CustomEvent<{ scrollTop: number }>) {
const scrollTop = event.detail.scrollTop + 5;
const anchors = this.anchors;
const count = anchors.length - 1;
let index = this.index;
- 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 initSearch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function initSearch() {
const searchEl = document.getElementById("tsd-search");
if (!searchEl) return;
const searchScript = document.getElementById(
- 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"