polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Function getInitial has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getInitial (defaultValue: RawParam, options: Option[]): Initial {
  if (defaultValue?.value) {
    if (defaultValue.value instanceof Enum) {
      return {
        initialEnum: defaultValue.value.type,
Severity: Minor
Found in packages/react-params/src/Param/Enum.tsx - About 1 hr to fix

    Function BasicAccountIdBase has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function BasicAccountIdBase (props: Props): React.ReactElement<Props> {
      const { bytesLength, className = '', defaultValue: { value }, isDisabled, isError, label, onChange } = props;
      const [defaultValue] = useState(() => (value as string)?.toString());
    
      const _onChange = useCallback(
    Severity: Minor
    Found in packages/react-params/src/Param/BasicAccountIdBase.tsx - About 1 hr to fix

      Function onSaveName has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          (): void => {
            if (isEditingName) {
              toggleIsEditingName();
            }
      
      
      Severity: Minor
      Found in packages/react-hooks/src/useAccountInfo.ts - About 1 hr to fix

        Function useParaApiImpl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function useParaApiImpl (paraId: BN | number): Result {
          const mountedRef = useIsMountedRef();
          const endpoints = useParaEndpoints(paraId);
          const [state, setState] = useState<Result>(() => ({
            api: null,
        Severity: Minor
        Found in packages/react-hooks/src/useParaApi.ts - About 1 hr to fix

          Function extractBaseInfo has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: DeriveStakingElected, waitingDerive: DeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial<SortedTargets> {
          Severity: Major
          Found in packages/page-staking-legacy/src/useSortedTargets.ts - About 1 hr to fix

            Function checkValue has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function checkValue (hasValue: boolean, value: string | null | undefined, minLength: number, includes: string[], excludes: string[], starting: string[], notStarting: string[] = WHITESPACE, notEnding: string[] = WHITESPACE): boolean {
            Severity: Major
            Found in packages/page-accounts/src/modals/IdentityMain.tsx - About 1 hr to fix

              Function extractBaseInfo has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: DeriveStakingElected, waitingDerive: DeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial<SortedTargets> {
              Severity: Major
              Found in packages/page-staking/src/useSortedTargets.ts - About 1 hr to fix

                Function getValues has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function getValues (api: ApiPromise, value: BN | string = BN_ZERO, si: SiDef | null, bitLength: BitLength, isSigned: boolean, isZeroable: boolean, maxValue?: BN | null, decimals?: number): [string, BN, boolean] {
                Severity: Major
                Found in packages/react-components/src/InputNumber.tsx - About 1 hr to fix

                  Function inputToBn has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function inputToBn (api: ApiPromise, input: string, si: SiDef | null, bitLength: BitLength, isSigned: boolean, isZeroable: boolean, maxValue?: BN | null, decimals?: number): [BN, boolean] {
                  Severity: Major
                  Found in packages/react-components/src/InputNumber.tsx - About 1 hr to fix

                    Function getValuesFromString has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function getValuesFromString (api: ApiPromise, value: string, si: SiDef | null, bitLength: BitLength, isSigned: boolean, isZeroable: boolean, maxValue?: BN | null, decimals?: number): [string, BN, boolean] {
                    Severity: Major
                    Found in packages/react-components/src/InputNumber.tsx - About 1 hr to fix

                      Function Pool has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Pool ({ className = '', members, ownAccounts, params, poolId }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const info = usePoolInfo(poolId);
                        const [isExpanded, toggleExpanded] = useToggle(false);
                      
                      
                      Severity: Minor
                      Found in packages/page-staking2/src/Pools/Pool.tsx - About 55 mins 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 CreateEthDerivationPath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function CreateEthDerivationPath ({ className, derivePath, deriveValidation, onChange, seedType }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const [addIndex, setAddIndex] = useState(0);
                        const [customIndex, setCustomIndex] = useState<BN | undefined>(BN_ZERO);
                        const [addressList] = useState<{ key: number; text: ReactNode; value: number; }[]>(
                      Severity: Minor
                      Found in packages/page-accounts/src/modals/CreateEthDerivationPath.tsx - About 55 mins 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 StakingApp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const { areAccountsLoaded, hasAccounts } = useAccounts();
                        const { pathname } = useLocation();
                      Severity: Minor
                      Found in packages/page-staking-legacy/src/index.tsx - About 55 mins 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 Status has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Status ({ className, heartbeat: { authoredBlocks, isOnline } = {}, isChilled, nominators, validator: { isElected, isPara } }: Props): React.ReactElement<Props> {
                        const { allAccounts } = useAccounts();
                      
                        const isNominating = useMemo(
                          () => nominators && nominators.some((a) => allAccounts.includes(a)),
                      Severity: Minor
                      Found in packages/page-staking2/src/Validators/Active/Status.tsx - About 55 mins 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 Code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Code ({ className, code, onShowDeploy }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const optCode = useCall<Option<Codec>>(api.query.contracts.pristineCode || api.query.contracts.codeStorage, [code.json.codeHash]);
                        const [isForgetOpen, toggleIsForgetOpen] = useToggle();
                      Severity: Minor
                      Found in packages/page-contracts/src/Codes/Code.tsx - About 55 mins 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 Add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Add ({ onClose }: Props): React.ReactElement {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const [address, setAddress] = useState<string | null>(null);
                        const [isAddressValid, setIsAddressValid] = useState(false);
                      Severity: Minor
                      Found in packages/page-contracts/src/Contracts/Add.tsx - About 55 mins 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 Summary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Summary ({ avgStaked, className, lastEra, lowStaked, minNominated, minNominatorBond, stakedReturn, totalIssuance, totalStaked }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const lastReward = useCall<BN>(lastEra && api.query.staking.erasValidatorReward, [lastEra], OPT_REWARD);
                      
                      
                      Severity: Minor
                      Found in packages/page-staking-legacy/src/Targets/Summary.tsx - About 55 mins 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 Summary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Summary ({ avgStaked, className, lastEra, lowStaked, minNominated, minNominatorBond, stakedReturn, totalIssuance, totalStaked }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const lastReward = useCall<BN>(lastEra && api.query.staking.erasValidatorReward, [lastEra], OPT_REWARD);
                      
                      
                      Severity: Minor
                      Found in packages/page-staking/src/Targets/Summary.tsx - About 55 mins 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 StakingApp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                        const { areAccountsLoaded, hasAccounts } = useAccounts();
                        const { pathname } = useLocation();
                      Severity: Minor
                      Found in packages/page-staking/src/index.tsx - About 55 mins 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 Summary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function Summary ({ className, issuanceActive, issuanceInactive, issuanceTotal, summary: { refActive, refCount }, withIssuance }: Props): React.ReactElement<Props> {
                        const { t } = useTranslation();
                        const { api } = useApi();
                      
                        return (
                      Severity: Minor
                      Found in packages/page-referenda/src/Referenda/Summary.tsx - About 55 mins 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

                      Severity
                      Category
                      Status
                      Source
                      Language