Showing 600 of 2,050 total issues
Function Row
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function Row ({ address, buttons, children, className = '', defaultName, details, icon, iconInfo, isDisabled, isEditableName, isEditableTags, isInline, isShortAddr = true, name, onChangeName, onChangeTags, onSaveName, onSaveTags, tags }: RowProps): React.ReactElement<RowProps> {
const [isEditingName, toggleIsEditingName] = useToggle();
const [isEditingTags, toggleIsEditingTags] = useToggle();
const _onSaveName = useCallback((): void => {
- 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 BlockByHash
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function BlockByHash ({ className = '', error, value }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const mountedRef = useIsMountedRef();
const [{ events, getBlock, getHeader, runtimeVersion }, setState] = useState<State>({});
- 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 ExtrinsicDisplay
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function ExtrinsicDisplay ({ blockNumber, className = '', events, index, maxBlockWeight, value, withLink }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const link = useMemo(
() => withLink
- 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 Playground
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function Playground ({ basePath, className = '' }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const apiProps = useApi();
const injectedRef = useRef<Injected | null>(null);
const [code, setCode] = useState('');
- 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 _onInputFile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const _onInputFile = useCallback<FunInputFile>((e) => {
const files = e.target.files;
if (!files) {
return;
Function useInactivesImpl
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useInactivesImpl (stashId: string, nominees?: string[]): Inactives {
const { api } = useApi();
const mountedRef = useIsMountedRef();
const [state, setState] = useState<Inactives>({});
const indexes = useCall<DeriveSessionIndexes>(api.derive.session.indexes);
Function StructParam
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function StructParam (props: Props): React.ReactElement<Props> {
const params = useParamDefs(props.registry, props.type);
const { className = '', defaultValue, isDisabled, label, onChange, overrides, withLabel } = props;
const [values] = useState(() => extractValues(defaultValue));
Function extractParaMap
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractParaMap (hasLinksMap: Record<string, boolean>, paraIds: ParaId[], leases: Option<ITuple<[AccountId, BalanceOf]>>[][]): Result {
return paraIds
.reduce((all: Result, id, index): Result => {
all.push([
id,
Function findComponent
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function findComponent (registry: Registry, def: TypeDef, overrides: ComponentMap = {}): React.ComponentType<Props> {
// Explicit/special handling for Account20/32 types where they don't match
// the actual chain we are connected to
if (['AccountId20', 'AccountId32'].includes(def.type)) {
const defType = `AccountId${registry.createType('AccountId').length}`;
Function useInactivesImpl
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useInactivesImpl (stashId: string, nominees?: string[]): Inactives {
const { api } = useApi();
const mountedRef = useIsMountedRef();
const [state, setState] = useState<Inactives>({});
const indexes = useCall<DeriveSessionIndexes>(api.derive.session.indexes);
Function useAvailableSlashesImpl
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useAvailableSlashesImpl (): [BN, PalletStakingUnappliedSlash[]][] {
const { api } = useApi();
const indexes = useCall<DeriveSessionIndexes>(api.derive.session?.indexes);
const earliestSlash = useCall<Option<EraIndex>>(api.query.staking?.earliestUnappliedSlash);
const mountedRef = useIsMountedRef();
Function extractRewards
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractRewards (labels: string[], erasRewards: DeriveEraRewards[], ownSlashes: DeriveOwnSlashes[], allPoints: DeriveStakerPoints[], divisor: BN): LineData {
const slashSet = new Array<number>(labels.length);
const rewardSet = new Array<number>(labels.length);
const avgSet = new Array<number>(labels.length);
const [total, avgCount] = erasRewards.reduce(([total, avgCount], { era, eraReward }) => {
Function createResult
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createResult (bestNumber: BlockNumber, minContribution: BN, funds: Campaign[], leased: ParaId[], prev: Campaigns): Campaigns {
const [activeRaised, activeCap, totalRaised, totalCap] = funds.reduce(([ar, ac, tr, tc], { info: { cap, end, raised }, isWinner }) => [
(bestNumber.gt(end) || isWinner) ? ar : ar.iadd(raised),
(bestNumber.gt(end) || isWinner) ? ac : ac.iadd(cap),
tr.iadd(raised),
Function valueToText
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function valueToText (type: string, value: Codec | undefined | null): React.ReactNode {
if (isNull(value) || isUndefined(value)) {
const { cName, key, values } = div({}, '<unknown>');
return (
Function extractRewards
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractRewards (labels: string[], erasRewards: DeriveEraRewards[], ownSlashes: DeriveOwnSlashes[], allPoints: DeriveStakerPoints[], divisor: BN): LineData {
const slashSet = new Array<number>(labels.length);
const rewardSet = new Array<number>(labels.length);
const avgSet = new Array<number>(labels.length);
const [total, avgCount] = erasRewards.reduce(([total, avgCount], { era, eraReward }) => {
Function getValRewards
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getValRewards (api: ApiPromise, validatorEras: ValidatorWithEras[], erasPoints: DeriveEraPoints[], erasRewards: DeriveEraRewards[]): State {
const allRewards: Record<string, DeriveStakerReward[]> = {};
validatorEras.forEach(({ eras, stashId }): void => {
eras.forEach((era): void => {
Function useWinningDataImpl
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useWinningDataImpl (auctionInfo?: AuctionInfo): Winning[] | undefined {
const { api } = useApi();
const mountedRef = useIsMountedRef();
const ranges = useLeaseRanges();
const [result, setResult] = useState<Winning[] | undefined>();
Function createOptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function createOptions (runtime: Record<string, Record<string, DefinitionCallNamed>>, sectionName?: string | null): DropdownOptions {
if (!sectionName) {
return [];
}
Function createApi
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createApi (apiUrl: string, signer: ApiSigner, isLocalFork: boolean, onError: (error: unknown) => void): Promise<CreateApiReturn> {
const types = getDevTypes();
const isLight = apiUrl.startsWith('light://');
let provider;
let chopsticksFork: Blockchain | null = null;
Consider simplifying this complex logical expression. Open
if (isHeader) {
lastHeader = text as string;
} else {
it(`${lastHeader}:: ${text as string}:: ${textBy}`, (): void => {
const item = filtered[index - 1];