polkadot-js/apps

View on GitHub

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 => {
Severity: Minor
Found in packages/react-components/src/Row.tsx - About 1 hr to fix

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>({});
Severity: Minor
Found in packages/page-explorer/src/BlockInfo/ByHash.tsx - About 1 hr to fix

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
Severity: Minor
Found in packages/page-explorer/src/BlockInfo/Extrinsic.tsx - About 1 hr to fix

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('');
Severity: Minor
Found in packages/page-js/src/Playground.tsx - About 1 hr to fix

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;
Severity: Minor
Found in packages/page-files/src/CrustFiles.tsx - About 1 hr to fix

    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);
    Severity: Minor
    Found in packages/page-staking-legacy/src/Actions/useInactives.ts - About 1 hr to fix

      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));
      
      
      Severity: Minor
      Found in packages/react-params/src/Param/Struct.tsx - About 1 hr to fix

        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,
        Severity: Minor
        Found in packages/page-parachains/src/Parathreads/useParaMap.ts - About 1 hr to fix

          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}`;
          Severity: Minor
          Found in packages/react-params/src/Param/findComponent.ts - About 1 hr to fix

            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);
            Severity: Minor
            Found in packages/page-staking/src/Actions/useInactives.ts - About 1 hr to fix

              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();
              Severity: Minor
              Found in packages/react-hooks/src/useAvailableSlashes.ts - About 1 hr to fix

                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 }) => {
                Severity: Minor
                Found in packages/page-staking-legacy/src/Query/ChartRewards.tsx - About 1 hr to fix

                  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),
                  Severity: Minor
                  Found in packages/page-parachains/src/useFunds.ts - About 1 hr to fix

                    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 (
                    Severity: Minor
                    Found in packages/react-params/src/valueToText.tsx - About 1 hr to fix

                      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 }) => {
                      Severity: Minor
                      Found in packages/page-staking/src/Query/ChartRewards.tsx - About 1 hr to fix

                        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 => {
                        Severity: Minor
                        Found in packages/react-hooks/src/useOwnEraRewards.ts - About 1 hr to fix

                          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>();
                          Severity: Minor
                          Found in packages/page-parachains/src/useWinningData.ts - About 1 hr to fix

                            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 [];
                              }
                            
                            
                            Severity: Minor
                            Found in packages/react-components/src/InputCalls/options/method.tsx - About 1 hr to fix

                              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;
                              Severity: Minor
                              Found in packages/react-api/src/Api.tsx - About 1 hr to fix

                                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];
                                Severity: Critical
                                Found in packages/apps-config/src/endpoints/index.spec.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language