polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Function getPoints has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getPoints (all: ApiStats[]): ChartInfo {
  const bytesChart: ChartContents = {
    labels: [],
    values: [[], [], []]
  };
Severity: Minor
Found in packages/page-explorer/src/Api/index.tsx - About 1 hr to fix

    Function calculateOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function calculateOptions (aspectRatio: number, values: Value[], jsonValues: string, max: number, showLabels: boolean): State {
      const chartData = values.reduce((data, { colors: [normalColor = '#00f', hoverColor], label, value }): Config => {
        const dataset = data.datasets[0];
    
        dataset.backgroundColor.push(alphaColor(normalColor));
    Severity: Minor
    Found in packages/react-components/src/Chart/HorizBar.tsx - About 1 hr to fix

      Function groupByValidator has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function groupByValidator (allRewards: Record<string, DeriveStakerReward[]>): PayoutValidator[] {
        return Object
          .entries(allRewards)
          .reduce((grouped: PayoutValidator[], [stashId, rewards]): PayoutValidator[] => {
            rewards
      Severity: Minor
      Found in packages/page-staking-legacy/src/Payouts/index.tsx - About 1 hr to fix

        Function groupByValidator has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function groupByValidator (allRewards: Record<string, DeriveStakerReward[]>): PayoutValidator[] {
          return Object
            .entries(allRewards)
            .reduce((grouped: PayoutValidator[], [stashId, rewards]): PayoutValidator[] => {
              rewards
        Severity: Minor
        Found in packages/page-staking/src/Payouts/index.tsx - About 1 hr to fix

          Function getValues has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getValues (selectedId: string | null | undefined, noDefault: boolean | undefined, allBalances: DeriveBalancesAll, existential: BN): ValueState {
            const sortedLocks = allBalances.lockedBreakdown
              // first sort by amount, so greatest value first
              .sort((a, b) =>
                b.amount.cmp(a.amount)
          Severity: Minor
          Found in packages/react-components/src/VoteValue.tsx - About 1 hr to fix

            Function createOptions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function createOptions (api: ApiPromise, sectionName: string, filter?: (section: string, method?: string) => boolean): DropdownOptions {
              const section = api.tx[sectionName];
              const isAllowed = !filter || filter(sectionName);
            
              if (!section || Object.keys(section).length === 0 || !isAllowed) {
            Severity: Minor
            Found in packages/react-components/src/InputExtrinsic/options/method.tsx - About 1 hr to fix

              Function extractEvents has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function extractEvents (api: ApiPromise, lastBlock: SignedBlockExtended, prev: Result): Result {
                const backed: EventMap = {};
                const included: EventMap = {};
                const timeout: EventMap = {};
                const blockNumber = lastBlock.block.header.number.unwrap();
              Severity: Minor
              Found in packages/page-parachains/src/Overview/useEvents.ts - About 1 hr to fix

                Function UserIcon has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function UserIcon (): React.ReactElement {
                  return (
                    <svg
                      fill='none'
                      height='40'
                Severity: Minor
                Found in packages/react-components/src/AccountSidebar/UserIcon.tsx - About 1 hr to fix

                  Function updateAddress has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function updateAddress (seed: string, derivePath: string, seedType: SeedType, pairType: PairType): AddressState {
                    let address: string | null = null;
                    let deriveValidation: DeriveValidationOutput = deriveValidate(seed, seedType, derivePath, pairType);
                    let isSeedValid = false;
                  
                  
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/Create.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 MultisigApprove has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function MultisigApprove ({ className = '', onClose, ongoing, threshold = 0, who = [] }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const { api } = useApi();
                    const { allAccounts } = useAccounts();
                    const [callHex, setCallHex] = useState<string>('');
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/MultisigApprove.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 Address has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Address ({ address, className = '', filterName, hasQueries, isElected, isFavorite, isMain, isPara, lastBlock, minCommission, nominatedBy, points, recentlyOnline, toggleFavorite, validatorInfo, withIdentity }: Props): React.ReactElement<Props> | null {
                    const { t } = useTranslation();
                    const { api, apiIdentity } = useApi();
                    const [isExpanded, toggleIsExpanded] = useToggle(false);
                    const { accountInfo, slashingSpans } = useAddressCalls(api, address, isMain);
                  Severity: Minor
                  Found in packages/page-staking-legacy/src/Validators/Address/index.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 ProxyOverview has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function ProxyOverview ({ className, onClose, previousProxy: [existing] = EMPTY_EXISTING, proxiedAccount }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const { api } = useApi();
                    const [batchPrevious, setBatchPrevious] = useState<SubmittableExtrinsic<'promise'>[]>([]);
                    const [batchAdded, setBatchAdded] = useState<SubmittableExtrinsic<'promise'>[]>([]);
                  Severity: Minor
                  Found in packages/page-accounts/src/modals/ProxyOverview.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 EventDisplay has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function EventDisplay ({ children, className = '', eventName, value, withExpander }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const names = value.data.names;
                    const params = value.typeDef.map((type, i) => ({
                      name: names?.[i] || undefined,
                  Severity: Minor
                  Found in packages/react-params/src/Named/Event.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 Address has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Address ({ address, className = '', filterName, hasQueries, isElected, isFavorite, isMain, isPara, lastBlock, minCommission, nominatedBy, points, recentlyOnline, toggleFavorite, validatorInfo, withIdentity }: Props): React.ReactElement<Props> | null {
                    const { t } = useTranslation();
                    const { api, apiIdentity } = useApi();
                    const [isExpanded, toggleIsExpanded] = useToggle(false);
                    const { accountInfo, slashingSpans } = useAddressCalls(api, address, isMain);
                  Severity: Minor
                  Found in packages/page-staking/src/Validators/Address/index.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 EnumParam has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function EnumParam (props: Props): React.ReactElement<Props> {
                    const { className = '', defaultValue, isDisabled, isError, label, onChange, overrides, registry, type, withLabel } = props;
                    const [{ options, subTypes }] = useState<Options>(() => getOptions(registry, type));
                    const [current, setCurrent] = useState<ParamDef[] | null>(() => getCurrent(registry, type, defaultValue, subTypes));
                    const [{ initialEnum, initialParams }, setInitial] = useState<Initial>(() => getInitial(defaultValue, options));
                  Severity: Minor
                  Found in packages/react-params/src/Param/Enum.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 Voting has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Voting ({ className, id, isConvictionVote, isMember, members, palletVote, preimage, ranks, trackInfo }: Props): React.ReactElement<Props> | null {
                    const { t } = useTranslation();
                    const { api } = useApi();
                    const { allAccounts, hasAccounts } = useAccounts();
                    const [accountId, setAccountId] = useState<string | null>(null);
                  Severity: Minor
                  Found in packages/page-referenda/src/Referenda/Vote/index.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 createResult has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function createResult (interimResult: PreimageStatus, optBytes: Option<Bytes> | Uint8Array): Preimage {
                    const callData = isU8a(optBytes)
                      ? optBytes
                      : optBytes.unwrapOr(null);
                    let proposal: Call | null = null;
                  Severity: Minor
                  Found in packages/react-hooks/src/usePreimage.ts - 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 Endpoints has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const linkOptions = createWsEndpoints(t);
                    const { isLocalFork } = useApi();
                    const [groups, setGroups] = useState(() => combineEndpoints(linkOptions));
                  Severity: Minor
                  Found in packages/apps/src/Endpoints/index.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 Address has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Address ({ address, className = '', filter, isFavorite, toggleFavorite }: Props): React.ReactElement<Props> | null {
                    const { t } = useTranslation();
                    const api = useApi();
                    const info = useDeriveAccountInfo(address);
                    const balancesAll = useBalancesAll(address);
                  Severity: Minor
                  Found in packages/page-addresses/src/Contacts/Address.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 Sign has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Sign ({ className = '' }: Props): React.ReactElement<Props> {
                    const { t } = useTranslation();
                    const [currentPair, setCurrentPair] = useState<KeyringPair | null>(() => keyring.getPairs()[0] || null);
                    const [{ data, isHexData }, setData] = useState<DataState>({ data: '', isHexData: false });
                    const [{ isInjected }, setAccountState] = useState<AccountState>({ isExternal: false, isHardware: false, isInjected: false });
                  Severity: Minor
                  Found in packages/page-signing/src/Sign.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

                  Severity
                  Category
                  Status
                  Source
                  Language