polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Avoid deeply nested control flow statements.
Open

          if (defValue === null) {
            defValue = meta;
          }
Severity: Major
Found in packages/react-components/src/InputCalls/useRuntime.ts - About 45 mins to fix

    Function General has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function General ({ className = '' }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const { chainSS58, isApiReady, isElectron } = useApi();
      const { isIpfs } = useIpfs();
      const { hasLedgerChain, hasWebUsb } = useLedger();
    Severity: Minor
    Found in packages/page-settings/src/General.tsx - About 45 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 format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const format = (value: unknown): string => {
      if (isError(value)) {
        return value.stack
          ? value.stack
          : value.toString();
    Severity: Minor
    Found in packages/page-js/src/Output.tsx - About 45 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 Bounty has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function Bounty ({ bestNumber, bounty, className = '', description, index, proposals }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const [isExpanded, toggleExpanded] = useToggle(false);
    
      const { bond, curatorDeposit, fee, proposer, status, value } = bounty;
    Severity: Minor
    Found in packages/page-bounties/src/Bounty.tsx - About 45 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 transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      transform: (data: string | undefined): CollectionSupportedMetadata | null => {
        if (!data) {
          return null;
        }
    
    
    Severity: Minor
    Found in packages/page-nfts/src/useCollectionInfos.ts - About 45 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 skipBalancesIf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function skipBalancesIf ({ withBalance = true, withExtended = false }: Props): boolean {
      // NOTE Unsure why we don't have a check for balancesAll in here (check skipStakingIf). adding
      // it doesn't break on Accounts/Addresses, but this gets used a lot, so there _may_ be an actual
      // reason behind the madness. However, derives are memoized, so no issue overall.
      if (withBalance === true || withExtended === true) {
    Severity: Minor
    Found in packages/react-components/src/AddressInfo.tsx - About 45 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 LinkExternal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function LinkExternal ({ className = '', data, hash, isSidebar, isSmall, isText, type, withTitle }: Props): React.ReactElement<Props> | null {
      const { t } = useTranslation();
      const { systemChain } = useApi();
    
      const links = useMemo(
    Severity: Minor
    Found in packages/react-components/src/LinkExternal.tsx - About 45 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 transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      transform: (data: string | undefined): ItemSupportedMetadata | null => {
        if (!data) {
          return null;
        }
    
    
    Severity: Minor
    Found in packages/page-nfts/src/AccountItems/useItemsInfos.ts - About 45 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 AddressRow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function AddressRow ({ buttons, children, className, defaultName, fullLength = false, isContract = false, isDisabled, isEditableName, isInline, isValid: propsIsValid, overlay, value, withTags = false }: Props): React.ReactElement<Props> | null {
      const { accountIndex, isNull, name, onSaveName, onSaveTags, setName, setTags, tags } = useAccountInfo(value ? value.toString() : null, isContract);
    
      const isValid = !isNull && (propsIsValid || value || accountIndex);
      const Icon = value ? IdentityIcon : BaseIdentityIcon;
    Severity: Minor
    Found in packages/react-components/src/AddressRow.tsx - About 45 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 Tip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members, onSelect, onlyUntipped, tip }: Props): React.ReactElement<Props> | null {
      const { api } = useApi();
      const { t } = useTranslation();
      const { allAccounts } = useAccounts();
    
    
    Severity: Minor
    Found in packages/page-treasury/src/Tips/Tip.tsx - About 45 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 Translate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function Translate ({ className }: Props): React.ReactElement<Props> {
      const { t } = useTranslation();
      const [withEmpty, toggleWithEmpty] = useToggle();
      const [{ english, keys, modules }, setDefaults] = useState<Defaults>({ english: {}, keys: [], modules: [] });
      const [lng, setLng] = useState<string>('zh');
    Severity: Minor
    Found in packages/page-settings/src/I18n/index.tsx - About 45 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

    Consider simplifying this complex logical expression.
    Open

          if (newRaise && auctionInfo?.leasePeriod && campaigns.funds) {
            const leasePeriodStart = auctionInfo.leasePeriod;
            const leasePeriodEnd = leasePeriodStart.add(rangeMax);
    
            return campaigns.funds
    Severity: Major
    Found in packages/page-parachains/src/Auctions/Auction.tsx - About 40 mins to fix

      Function setAdditionalFieldData has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function setAdditionalFieldData (api: ApiPromise, info: IdentityInfo, key: string, setActive: null | ((isActive: boolean) => void), setVal: (val: string) => void): Data {
      Severity: Minor
      Found in packages/page-accounts/src/modals/IdentityMain.tsx - About 35 mins to fix

        Function queryLedger has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        async function queryLedger (api: ApiPromise, getLedger: () => Ledger, name: string, accountOffset: number, addressOffset: number): Promise<void> {
        Severity: Minor
        Found in packages/page-accounts/src/modals/Ledger.tsx - About 35 mins to fix

          Function applyFilter has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function applyFilter (validators: ValidatorInfo[], medianComm: number, allIdentity: Record<string, DeriveHasIdentity>, { daysPayout, isBabe, maxPaid, withElected, withGroup, withIdentity, withPayout, withoutComm, withoutOver }: Flags, nominatedBy?: NominatedByMap): ValidatorInfo[] {
          Severity: Minor
          Found in packages/page-staking-legacy/src/Targets/index.tsx - About 35 mins to fix

            Function extractRewards has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function extractRewards (labels: string[], erasRewards: DeriveEraRewards[], ownSlashes: DeriveOwnSlashes[], allPoints: DeriveStakerPoints[], divisor: BN): LineData {
            Severity: Minor
            Found in packages/page-staking-legacy/src/Query/ChartRewards.tsx - About 35 mins to fix

              Function canary has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function canary (ctx: CanvasRenderingContext2D, w: number, h: number, s: number, f: (ctx: CanvasRenderingContext2D, path: Path2D) => void): void {
              Severity: Minor
              Found in packages/page-society/src/draw/canary.ts - About 35 mins to fix

                Function sortAccounts has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                export function sortAccounts (accountsList: SortedAccount[], accountsMap: Record<string, SortedAccount>, balances: Record<string, AccountBalance>, by: SortCategory, fromMax: boolean): SortedAccount[] {
                Severity: Minor
                Found in packages/page-accounts/src/util.tsx - About 35 mins to fix

                  Function getMapMembers has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function getMapMembers (members: DeriveSocietyMember[], skeptics: string[], voters: string[], { defender, founder, hasDefender, head }: DeriveSociety, warnStrikes: BN): [MapMember[], BN] {
                  Severity: Minor
                  Found in packages/page-society/src/index.tsx - About 35 mins to fix

                    Function getFiltered has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function getFiltered (isOwn: boolean, stakingOverview: DeriveStakingOverview | undefined, favorites: string[], next?: string[], ownStashIds?: string[]): Filtered {
                    Severity: Minor
                    Found in packages/page-staking-legacy/src/Validators/CurrentList.tsx - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language