glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Consider simplifying this complex logical expression.
Open

  else if (
    followAccountSuccess.match(action) ||
    unfollowAccountSuccess.match(action) ||
    blockAccountSuccess.match(action) ||
    unblockAccountSuccess.match(action) ||
Severity: Critical
Found in app/javascript/mastodon/reducers/relationships.ts - About 1 hr to fix

    Function handleKeyDown has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const handleKeyDown = useCallback((e) => {
        if (disabled) {
          e.preventDefault();
          return;
        }
    Severity: Minor
    Found in app/javascript/flavours/glitch/components/autosuggest_textarea.jsx - About 1 hr to fix

      Function render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render () {
          const { status, intl, statusContent } = this.props;
      
          const renderReadMore = this.props.onClick && status.get('collapsed');
          const contentLocale = intl.locale.replace(/[_-].*/, '');
      Severity: Minor
      Found in app/javascript/flavours/glitch/components/status_content.jsx - About 1 hr to fix

        Function render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render () {
            const { account, hidden, hideTabs } = this.props;
        
            if (account === null) {
              return null;

          Function handleKeyDown has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const handleKeyDown = useCallback((e) => {
              if (disabled) {
                e.preventDefault();
                return;
              }
          Severity: Minor
          Found in app/javascript/mastodon/components/autosuggest_textarea.jsx - About 1 hr to fix

            Function render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render () {
                const { status, intl, statusContent } = this.props;
            
                const renderReadMore = this.props.onClick && status.get('collapsed');
                const contentLocale = intl.locale.replace(/[_-].*/, '');
            Severity: Minor
            Found in app/javascript/mastodon/components/status_content.jsx - About 1 hr to fix

              Function handlePush has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const handlePush = (event) => {
                const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();
              
                // Placeholder until more information can be loaded
                event.waitUntil(
              Severity: Minor
              Found in app/javascript/mastodon/service_worker/web_push_notifications.js - About 1 hr to fix

                Function expandNormalizedNotifications has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const expandNormalizedNotifications = (state, notifications, next, isLoadingMore, isLoadingRecent, usePendingItems) => {
                  // This method is pretty tricky because:
                  // - existing notifications might be out of order
                  // - the existing notifications may have gaps, most often explicitly noted with a `null` item
                  // - ideally, we don't want it to reorder existing items
                Severity: Minor
                Found in app/javascript/mastodon/reducers/notifications.js - About 1 hr to fix

                  Function fillNotificationsGap has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function fillNotificationsGap(
                    groups: NotificationGroupsState['groups'],
                    gap: NotificationGap,
                    notifications: ApiNotificationGroupJSON[],
                  ): NotificationGroupsState['groups'] {
                  Severity: Minor
                  Found in app/javascript/flavours/glitch/reducers/notification_groups.ts - About 1 hr to fix

                    Function fillNotificationsGap has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function fillNotificationsGap(
                      groups: NotificationGroupsState['groups'],
                      gap: NotificationGap,
                      notifications: ApiNotificationGroupJSON[],
                    ): NotificationGroupsState['groups'] {
                    Severity: Minor
                    Found in app/javascript/mastodon/reducers/notification_groups.ts - About 1 hr to fix

                      Function ColumnSettings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const ColumnSettings: React.FC = () => {
                        const settings = useAppSelector((state) => state.settings.get('home'));
                      
                        const dispatch = useAppDispatch();
                        const onChange = useCallback(

                        Function _updateLinks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _updateLinks () {
                            const node = this.node;
                        
                            if (!node) {
                              return;

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

                        const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, isLoadingRecent, usePendingItems) => {
                          // This method is pretty tricky because:
                          // - existing items in the timeline might be out of order
                          // - the existing timeline may have gaps, most often explicitly noted with a `null` item
                          // - ideally, we don't want it to reorder existing items of the timeline
                        Severity: Minor
                        Found in app/javascript/flavours/glitch/reducers/timelines.js - 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 render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          render () {
                            const { media, statusId, lang, intl, onClose } = this.props;
                            const { navigationHidden, zoomedIn, viewportWidth, viewportHeight } = this.state;
                        
                            const index = this.getIndex();

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

                        const ColumnLink = ({ icon, activeIcon, iconComponent, activeIconComponent, text, to, onClick, href, method, badge, transparent, optional, ...other }) => {
                          const match = useRouteMatch(to);
                          const className = classNames('column-link', { 'column-link--transparent': transparent, 'column-link--optional': optional });
                          const badgeElement = typeof badge !== 'undefined' ? <span className='column-link__badge'>{badge}</span> : null;
                          const iconElement = (typeof icon === 'string' || iconComponent) ? <Icon id={icon} icon={iconComponent} className='column-link__icon' /> : icon;

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

                          _updateLinks () {
                            const node = this.node;
                        
                            if (!node) {
                              return;

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

                          render () {
                            const { media, statusId, lang, intl, onClose } = this.props;
                            const { navigationHidden, zoomedIn, viewportWidth, viewportHeight } = this.state;
                        
                            const index = this.getIndex();
                        Severity: Minor
                        Found in app/javascript/mastodon/features/ui/components/media_modal.jsx - 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 expandNormalizedTimeline has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, isLoadingRecent, usePendingItems) => {
                          // This method is pretty tricky because:
                          // - existing items in the timeline might be out of order
                          // - the existing timeline may have gaps, most often explicitly noted with a `null` item
                          // - ideally, we don't want it to reorder existing items of the timeline
                        Severity: Minor
                        Found in app/javascript/mastodon/reducers/timelines.js - 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

                        Method _insert_record has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _insert_record(connection, values, returning)
                              return super unless values.is_a?(Hash) && values['reblog_of_id']&.value.present?
                        
                              primary_key = self.primary_key
                              primary_key_value = nil
                        Severity: Minor
                        Found in app/models/concerns/status/safe_reblog_insert.rb - 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

                        Method index has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def index
                            respond_to do |format|
                              format.html do
                                expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.hour) unless user_signed_in?
                              end
                        Severity: Minor
                        Found in app/controllers/following_accounts_controller.rb - 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