glitch-soc/mastodon

View on GitHub

Showing 4,938 of 4,938 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export function createNotificationRequestFromJSON(
  requestJSON: ApiNotificationRequestJSON,
): NotificationRequest {
  const { account, notifications_count, ...request } = requestJSON;

Severity: Major
Found in app/javascript/mastodon/models/notification_request.ts and 1 other location - About 1 hr to fix
app/javascript/flavours/glitch/models/notification_request.ts on lines 9..19

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function trimNotifications(state: NotificationGroupsState) {
  if (state.scrolledToTop && state.groups.length > NOTIFICATIONS_TRIM_LIMIT) {
    state.groups.splice(NOTIFICATIONS_TRIM_LIMIT);
    ensureTrailingGap(state.groups);
  }
app/javascript/mastodon/reducers/notification_groups.ts on lines 250..255

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export const submitMarkers = createAppAsyncThunk(
  'markers/submit',
  (params: { immediate?: boolean }, { dispatch }) => {
    debouncedSubmitMarkers(dispatch);

Severity: Major
Found in app/javascript/flavours/glitch/actions/markers.ts and 1 other location - About 1 hr to fix
app/javascript/mastodon/actions/markers.ts on lines 128..137

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 { account, hidden, hideTabs } = this.props;
    
        if (account === null) {
          return null;

      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 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 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 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def follow!(other_account, reblogs: nil, notify: nil, languages: nil, uri: nil, rate_limit: false, bypass_limit: false)
                      rel = active_relationships.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, languages: languages, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
                                                .find_or_create_by!(target_account: other_account)
                  
                      rel.show_reblogs = reblogs   unless reblogs.nil?
                  Severity: Major
                  Found in app/models/concerns/account/interactions.rb and 1 other location - About 1 hr to fix
                  app/models/concerns/account/interactions.rb on lines 127..137

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    def request_follow!(other_account, reblogs: nil, notify: nil, languages: nil, uri: nil, rate_limit: false, bypass_limit: false)
                      rel = follow_requests.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, languages: languages, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
                                           .find_or_create_by!(target_account: other_account)
                  
                      rel.show_reblogs = reblogs   unless reblogs.nil?
                  Severity: Major
                  Found in app/models/concerns/account/interactions.rb and 1 other location - About 1 hr to fix
                  app/models/concerns/account/interactions.rb on lines 114..124

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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(

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                    const defaultShouldUpdateScroll = (prevRouterProps, { location }) => {
                      // If the change is caused by opening a modal, do not scroll to top
                      return !(location.state?.mastodonModalKey && location.state?.mastodonModalKey !== prevRouterProps?.location?.state?.mastodonModalKey);
                    };
                    Severity: Major
                    Found in app/javascript/mastodon/containers/scroll_container.js and 1 other location - About 1 hr to fix
                    app/javascript/flavours/glitch/containers/scroll_container.js on lines 6..9

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                    const selectRepliedToAccountIds = createSelector(
                      [
                        (state) => state.get('statuses'),
                        (_, statusIds) => statusIds,
                      ],
                    Severity: Major
                    Found in app/javascript/mastodon/features/report/comment.jsx and 1 other location - About 1 hr to fix
                    app/javascript/flavours/glitch/features/report/comment.jsx on lines 21..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      onInteractionModal (type, status) {
                        dispatch(openModal({
                          modalType: 'INTERACTION',
                          modalProps: {
                            type,
                    Severity: Major
                    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
                    app/javascript/flavours/glitch/containers/status_container.js on lines 202..211

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      case TIMELINE_MARK_AS_PARTIAL:
                        return state.update(
                          action.timeline,
                          initialTimeline,
                          map => map.set('isPartial', true).set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('unread', 0),
                    Severity: Major
                    Found in app/javascript/flavours/glitch/reducers/timelines.js and 1 other location - About 1 hr to fix
                    app/javascript/mastodon/reducers/timelines.js on lines 224..229

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        dispatch(isUserTouching() ? openModal({
                          modalType: 'ACTIONS',
                          modalProps: {
                            status,
                            actions: items,
                    app/javascript/flavours/glitch/containers/dropdown_menu_container.js on lines 18..25

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                    function clearCustomEmojis(pool) {
                      customEmojisList.forEach((emoji) => {
                        let emojiId = emoji.id || emoji.short_names[0];
                    
                        delete pool[emojiId];
                    app/javascript/mastodon/features/emoji/emoji_mart_search_light.js on lines 32..39

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language