glitch-soc/mastodon

View on GitHub

Showing 1,287 of 4,903 total issues

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

export const useTimeout = () => {
  const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
  const callbackRef = useRef<() => void>();

  const set = useCallback((callback: () => void, delay: number) => {
Severity: Minor
Found in app/javascript/hooks/useTimeout.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 toShortNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function toShortNumber(sourceNumber: number): ShortNumber {
  if (sourceNumber < DECIMAL_UNITS.THOUSAND) {
    return [sourceNumber, DECIMAL_UNITS.ONE, 0];
  } else if (sourceNumber < DECIMAL_UNITS.MILLION) {
    return [
Severity: Minor
Found in app/javascript/flavours/glitch/utils/numbers.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 useLinks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const useLinks = () => {
  const history = useHistory();
  const dispatch = useAppDispatch();

  const handleHashtagClick = useCallback(
Severity: Minor
Found in app/javascript/flavours/glitch/hooks/useLinks.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 useLinks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const useLinks = () => {
  const history = useHistory();
  const dispatch = useAppDispatch();

  const handleHashtagClick = useCallback(
Severity: Minor
Found in app/javascript/hooks/useLinks.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 useTimeout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const useTimeout = () => {
  const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
  const callbackRef = useRef<() => void>();

  const set = useCallback((callback: () => void, delay: number) => {
Severity: Minor
Found in app/javascript/flavours/glitch/hooks/useTimeout.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 toShortNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function toShortNumber(sourceNumber: number): ShortNumber {
  if (sourceNumber < DECIMAL_UNITS.THOUSAND) {
    return [sourceNumber, DECIMAL_UNITS.ONE, 0];
  } else if (sourceNumber < DECIMAL_UNITS.MILLION) {
    return [
Severity: Minor
Found in app/javascript/mastodon/utils/numbers.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

Consider simplifying this complex logical expression.
Open

    } else if (attachment.get('type') === 'image') {
      const previewUrl   = attachment.get('preview_url');
      const previewWidth = attachment.getIn(['meta', 'small', 'width']);

      const originalUrl   = attachment.get('url');
Severity: Major
Found in app/javascript/flavours/glitch/components/media_gallery.jsx - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if (customEmojis === null) {
          while (i < str.length && (useSystemEmojiFont || !(unicode_emoji = trie.search(str.slice(i))))) {
            i += str.codePointAt(i) < 65536 ? 1 : 2;
          }
        } else {
    Severity: Major
    Found in app/javascript/flavours/glitch/features/emoji/emoji.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          } else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) {
            scrollableArea = (
              <div className={classNames('scrollable scrollable--flex', { fullscreen })} ref={this.setRef} onMouseMove={this.handleMouseMove}>
                <div role='feed' className='item-list'>
                  {prepend}
      Severity: Major
      Found in app/javascript/flavours/glitch/components/scrollable_list.jsx - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if (!onClick || e.button || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) {
              return;
            }
        Severity: Major
        Found in app/javascript/flavours/glitch/components/link.jsx - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (filter[3] || filter[4]) {
                warning = (
                  <span className='language-dropdown__dropdown__results__item__common-name'>
                    (
                    {filter[3] && <FormattedMessage id='filter_modal.select_filter.expired' defaultMessage='expired' />}
          Severity: Major
          Found in app/javascript/flavours/glitch/features/filters/select_filter.jsx - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

              if (typeof hasBoundingRectBug !== 'boolean') {
                const boundingRect = entry.target.getBoundingClientRect();
                const observerRect = entry.boundingClientRect;
                hasBoundingRectBug = boundingRect.height !== observerRect.height ||
                  boundingRect.top !== observerRect.top ||
            Severity: Major
            Found in app/javascript/flavours/glitch/features/ui/util/get_rect_from_entry.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  } else if (!statuses.isEmpty()) {
                    usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('pendingItems').isEmpty());
              
                    mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => {
                      const newIds = statuses.map(status => status.get('id'));
              Severity: Major
              Found in app/javascript/flavours/glitch/reducers/timelines.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (normalOldStatus && normalOldStatus.get('content') === normalStatus.content && normalOldStatus.get('spoiler_text') === normalStatus.spoiler_text) {
                    normalStatus.search_index = normalOldStatus.get('search_index');
                    normalStatus.contentHtml = normalOldStatus.get('contentHtml');
                    normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml');
                    normalStatus.spoiler_text = normalOldStatus.get('spoiler_text');
                Severity: Major
                Found in app/javascript/mastodon/actions/importer/normalizer.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      } else if (attachment.get('type') === 'image') {
                        const previewUrl   = attachment.get('preview_url');
                        const previewWidth = attachment.getIn(['meta', 'small', 'width']);
                  
                        const originalUrl   = attachment.get('url');
                  Severity: Major
                  Found in app/javascript/mastodon/components/media_gallery.jsx - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if (!newItems.isEmpty()) {
                          usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('pendingItems').isEmpty());
                    
                          mutable.update(usePendingItems ? 'pendingItems' : 'items', oldItems => {
                            // If called to poll *new* notifications, we just need to add them on top without duplicates
                    Severity: Major
                    Found in app/javascript/flavours/glitch/reducers/notifications.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (filter[3] || filter[4]) {
                            warning = (
                              <span className='language-dropdown__dropdown__results__item__common-name'>
                                (
                                {filter[3] && <FormattedMessage id='filter_modal.select_filter.expired' defaultMessage='expired' />}
                      Severity: Major
                      Found in app/javascript/mastodon/features/filters/select_filter.jsx - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                          if (typeof hasBoundingRectBug !== 'boolean') {
                            const boundingRect = entry.target.getBoundingClientRect();
                            const observerRect = entry.boundingClientRect;
                            hasBoundingRectBug = boundingRect.height !== observerRect.height ||
                              boundingRect.top !== observerRect.top ||
                        Severity: Major
                        Found in app/javascript/mastodon/features/ui/util/get_rect_from_entry.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              return unless (original_status.public_visibility? && status.public_visibility?) &&
                                            !(original_status.account.silenced? || status.account.silenced?) &&
                                            !(original_status.spoiler_text? || original_status.sensitive?)
                          Severity: Major
                          Found in app/models/trends/links.rb - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                } else if (!statuses.isEmpty()) {
                                  usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('pendingItems').isEmpty());
                            
                                  mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => {
                                    const newIds = statuses.map(status => status.get('id'));
                            Severity: Major
                            Found in app/javascript/mastodon/reducers/timelines.js - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language