polkadot-js/apps

View on GitHub

Showing 600 of 2,050 total issues

Function SidebarEditableSection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function SidebarEditableSection ({ accountIndex, address, isBeingEdited, onUpdateName, sidebarRef }: Props): React.ReactElement<Props> {
  const { flags, isEditing, isEditingName, isEditingTags, name, onForgetAddress, onSaveName, onSaveTags, setIsEditingName, setIsEditingTags, setName, setTags, tags, toggleIsEditingName, toggleIsEditingTags } = useAccountInfo(address);

  const refs = useMemo(
    () => [sidebarRef],

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 Modules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function Modules ({ className = '', onAdd }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();
  const { api } = useApi();
  const [{ defaultValues, isIterable, key, params }, setKey] = useState<KeyState>(() => ({ defaultValues: undefined, isHeadKey: true, isIterable: false, key: api.query.timestamp?.now || api.query.system.events, params: [] }));
  const [{ isValid, values }, setValues] = useState<ValState>(() => ({ isValid: true, values: [] }));
Severity: Minor
Found in packages/page-storage/src/Selection/Modules.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 StakingRedeemable has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function StakingRedeemable ({ className = '', isPool, stakingInfo }: Props): React.ReactElement<Props> | null {
  const { api } = useApi();
  const { allAccounts } = useAccounts();
  const { t } = useTranslation();
  const spanCount = useCall<number>(api.query.staking.slashingSpans, [stakingInfo?.stashId], OPT_SPAN);
Severity: Minor
Found in packages/react-components/src/StakingRedeemable.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 Tags has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function Tags ({ children, className = '', isEditable, isEditing, onChange, onSave, onToggleIsEditing, value, withEditButton = true, withTitle }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();

  const contents = useMemo(
    () => value.length
Severity: Minor
Found in packages/react-components/src/Tags.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 Summary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function Summary ({ events, maxBlockWeight, signedBlock }: Props): React.ReactElement<Props> | null {
  const { t } = useTranslation();
  const { api } = useApi();

  const [deposits, transfers, weight] = useMemo(
Severity: Minor
Found in packages/page-explorer/src/BlockInfo/Summary.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 AccountItems has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function AccountItems ({ className, infos = [] }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();
  const NO_NAME = ` - ${t('no name')} -`;

  const [infoIndex, setInfoIndex] = useState(0);
Severity: Minor
Found in packages/page-nfts/src/AccountItems/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 ProposalDisplay has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function ProposalDisplay ({ className = '', isMember, members, proposal: { council, id, proposal }, withSend }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();
  const { api } = useApi();
  const [isExpanded, toggleIsExpanded] = useToggle(false);

Severity: Minor
Found in packages/page-treasury/src/Overview/Proposal.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 redirect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function redirect (basePath: string, location: Location, items: (TabItem | false | null | undefined)[], hidden?: string[] | null | false): void {
  if (location.pathname !== basePath) {
    // Has the form /staking/query/<something>
    const [,, section] = location.pathname.split('/');
    const alias = items.find((v) => v && v.alias === section);
Severity: Minor
Found in packages/react-components/src/Tabs/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 useProxiesImpl has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function useProxiesImpl (address?: string | null): State | null {
  const { api } = useApi();
  const { allAccounts } = useAccounts();
  const mountedRef = useIsMountedRef();
  const [known, setState] = useState<State | null>(null);
Severity: Minor
Found in packages/page-accounts/src/Accounts/useProxies.ts - About 1 hr to fix

    Function extractState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function extractState (ownStashes?: StakerState[]): State {
      if (!ownStashes) {
        return {};
      }
    
    
    Severity: Minor
    Found in packages/page-staking-legacy/src/Actions/index.tsx - About 1 hr to fix

      Function dryRun has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async function dryRun () {
            let contract: SubmittableExtrinsic<'promise'> | null = null;
            let error: string | null = null;
      
            try {
      Severity: Minor
      Found in packages/page-contracts/src/Codes/Upload.tsx - About 1 hr to fix

        Function getTrackOptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getTrackOptions (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
          const includeBn = include?.map((v) => bnToBn(v));
          const excludeBn = exclude?.map((v) => bnToBn(v));
        
          return tracks
        Severity: Minor
        Found in packages/page-referenda/src/Referenda/Submit/useTrackOptions.tsx - About 1 hr to fix

          Function extractState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function extractState (ownStashes?: StakerState[]): State {
            if (!ownStashes) {
              return {};
            }
          
          
          Severity: Minor
          Found in packages/page-staking/src/Actions/index.tsx - About 1 hr to fix

            Function CallDisplay has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function CallDisplay (props: Props): React.ReactElement<Props> {
              const { t } = useTranslation();
              const { className = '', defaultValue: { value }, isDisabled, label, withLabel } = props;
            
              if (!isDisabled) {
            Severity: Minor
            Found in packages/react-params/src/Param/Call.tsx - About 1 hr to fix

              Function _onChangeAddress has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  (addressInput: string): void => {
                    let address = '';
                    let isAddressValid = true;
                    let isAddressExisting = false;
                    let isPublicKey = false;
              Severity: Minor
              Found in packages/page-addresses/src/modals/Create.tsx - About 1 hr to fix

                Function getStatus has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getStatus (api: ApiPromise, bestNumber: BlockNumber, votes: Votes, numMembers: number, section: CollectiveType): State {
                  const [instance] = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), section) || [section];
                  const modLocation = isFunction(api.tx[instance as 'technicalCommittee']?.close)
                    ? instance
                    : null;
                Severity: Minor
                Found in packages/react-hooks/src/useVotingStatus.ts - About 1 hr to fix

                  Function Entry has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function Entry (): React.ReactElement | null {
                    const bestNumber = useBestNumber();
                    const { value } = useParams<{ value: string }>();
                    const [stateValue, setStateValue] = useState<string | undefined>(value);
                  
                  
                  Severity: Minor
                  Found in packages/page-explorer/src/BlockInfo/index.tsx - About 1 hr to fix

                    Function retrieveAll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function retrieveAll (): Promise<Defaults> {
                      const _keys = await retrieveJson('index.json') as string[];
                      const keys = _keys.filter((lng) => lng !== 'en');
                      const missing = keys.filter((lng) => !languageCache[lng]);
                      const english = await retrieveEnglish();
                    Severity: Minor
                    Found in packages/page-settings/src/I18n/index.tsx - About 1 hr to fix

                      Function extractTipState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function extractTipState (tip: PalletTipsOpenTip | OpenTipTo225, allAccounts: string[]): TipState {
                        const closesAt = tip.closes.unwrapOr(null);
                        let finder: AccountId | null = null;
                        let deposit: Balance | null = null;
                      
                      
                      Severity: Minor
                      Found in packages/page-treasury/src/Tips/Tip.tsx - About 1 hr to fix

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

                            (): void => {
                              const account = address && keyring.getPair(address);
                        
                              if (!account) {
                                return;
                        Severity: Minor
                        Found in packages/page-accounts/src/modals/ChangePass.tsx - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language