glitch-soc/mastodon

View on GitHub

Showing 4,906 of 4,906 total issues

Function userLists has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function userLists(state = initialState, action) {
  switch(action.type) {
  case FOLLOWERS_FETCH_SUCCESS:
    return normalizeList(state, ['followers', action.id], action.accounts, action.next);
  case FOLLOWERS_EXPAND_SUCCESS:
Severity: Major
Found in app/javascript/mastodon/reducers/user_lists.js - About 3 hrs to fix

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

      render () {
        const { multiColumn, intl, server, extendedDescription, domainBlocks } = this.props;
        const isLoading = server.get('isLoading');
    
        return (
    Severity: Major
    Found in app/javascript/flavours/glitch/features/about/index.jsx - About 3 hrs to fix

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

      export const navigateToStatus = (statusId) => {
        return (_dispatch, getState) => {
          const state = getState();
          const accountId = state.statuses.getIn([statusId, 'account']);
          const acct = state.accounts.getIn([accountId, 'acct']);
      Severity: Major
      Found in app/javascript/flavours/glitch/actions/statuses.js and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/actions/statuses.js on lines 371..381

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

      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 COMPOSE_UPLOAD_CHANGE_SUCCESS:
          return state
            .set('is_changing_upload', false)
            .setIn(['media_modal', 'dirty'], false)
            .update('media_attachments', list => list.map(item => {
      Severity: Major
      Found in app/javascript/flavours/glitch/reducers/compose.js and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/reducers/compose.js on lines 461..471

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

      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

      export const navigateToStatus = (statusId) => {
        return (_dispatch, getState) => {
          const state = getState();
          const accountId = state.statuses.getIn([statusId, 'account']);
          const acct = state.accounts.getIn([accountId, 'acct']);
      Severity: Major
      Found in app/javascript/mastodon/actions/statuses.js and 1 other location - About 3 hrs to fix
      app/javascript/flavours/glitch/actions/statuses.js on lines 372..382

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

      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 COMPOSE_UPLOAD_CHANGE_SUCCESS:
          return state
            .set('is_changing_upload', false)
            .setIn(['media_modal', 'dirty'], false)
            .update('media_attachments', list => list.map(item => {
      Severity: Major
      Found in app/javascript/mastodon/reducers/compose.js and 1 other location - About 3 hrs to fix
      app/javascript/flavours/glitch/reducers/compose.js on lines 566..576

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

      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

        const prependBanner = feedType === 'community' ? (
          <DismissableBanner id='community_timeline'>
            <FormattedMessage
              id='dismissable_banner.community_timeline'
              defaultMessage='These are the most recent public posts from people whose accounts are hosted by {domain}.'
      Severity: Major
      Found in app/javascript/flavours/glitch/features/firehose/index.jsx and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/features/firehose/index.jsx on lines 124..140

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

      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

        const prependBanner = feedType === 'community' ? (
          <DismissableBanner id='community_timeline'>
            <FormattedMessage
              id='dismissable_banner.community_timeline'
              defaultMessage='These are the most recent public posts from people whose accounts are hosted by {domain}.'
      Severity: Major
      Found in app/javascript/mastodon/features/firehose/index.jsx and 1 other location - About 3 hrs to fix
      app/javascript/flavours/glitch/features/firehose/index.jsx on lines 150..166

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

      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

        state = {
          width: this.props.width,
          currentTime: 0,
          buffer: 0,
          duration: null,
      Severity: Major
      Found in app/javascript/flavours/glitch/features/audio/index.jsx and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/features/audio/index.jsx on lines 66..76

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

      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

        state = {
          width: this.props.width,
          currentTime: 0,
          buffer: 0,
          duration: null,
      Severity: Major
      Found in app/javascript/mastodon/features/audio/index.jsx and 1 other location - About 3 hrs to fix
      app/javascript/flavours/glitch/features/audio/index.jsx on lines 66..76

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

      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

        const handleFollow = useCallback(() => {
          if (!account) return;
      
          if (
            account.getIn(['relationship', 'following']) ||
      app/javascript/mastodon/features/directory/components/account_card.tsx on lines 80..93

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

      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

      const isJRDLink = (link: unknown): link is JRDLink =>
        typeof link === 'object' &&
        link !== null &&
        'rel' in link &&
        typeof link.rel === 'string' &&
      app/javascript/entrypoints/remote_interaction_helper.ts on lines 21..27

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

      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

      const isJRDLink = (link: unknown): link is JRDLink =>
        typeof link === 'object' &&
        link !== null &&
        'rel' in link &&
        typeof link.rel === 'string' &&
      Severity: Major
      Found in app/javascript/entrypoints/remote_interaction_helper.ts and 1 other location - About 3 hrs to fix
      app/javascript/flavours/glitch/entrypoints/remote_interaction_helper.ts on lines 21..27

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

      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

        const handleFollow = useCallback(() => {
          if (!account) return;
      
          if (
            account.getIn(['relationship', 'following']) ||
      app/javascript/flavours/glitch/features/directory/components/account_card.tsx on lines 80..93

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

      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

      File create.rb has 324 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class ActivityPub::Activity::Create < ActivityPub::Activity
        include FormattingHelper
      
        def perform
          @account.schedule_refresh_if_stale!
      Severity: Minor
      Found in app/lib/activitypub/activity/create.rb - About 3 hrs to fix

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

          render () {
            const { multiColumn, intl, server, extendedDescription, domainBlocks } = this.props;
            const isLoading = server.get('isLoading');
        
            return (
        Severity: Major
        Found in app/javascript/mastodon/features/about/index.jsx - About 3 hrs to fix

          Function render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            render () {
              const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, lang, letterbox, fullwidth, detailed, sensitive, editable, blurhash, autoFocus } = this.props;
              const { currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, revealed } = this.state;
              const progress = Math.min((currentTime / duration) * 100, 100);
              const muted = this.state.muted || volume === 0;
          Severity: Minor
          Found in app/javascript/flavours/glitch/features/video/index.jsx - About 3 hrs 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 perform has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform
              return if under_load?
          
              budget = compute_budget
          
          
          Severity: Minor
          Found in app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb - About 3 hrs 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 make has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def make
                return File.open(@file.path) unless needs_convert?
          
                dst = TempfileFactory.new.generate([@basename, @format ? ".#{@format}" : @current_format].join)
          
          
          Severity: Minor
          Found in lib/paperclip/vips_lazy_thumbnail.rb - About 3 hrs 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

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

                      {!columns.some(column => column.get('id') === 'PUBLIC') && (
                        <Link to='/public' className='drawer__tab' title={intl.formatMessage(messages.public)} aria-label={intl.formatMessage(messages.public)}><Icon id='globe' icon={PublicIcon} /></Link>
                      )}
          Severity: Major
          Found in app/javascript/flavours/glitch/features/compose/index.jsx and 6 other locations - About 3 hrs to fix
          app/javascript/flavours/glitch/features/compose/index.jsx on lines 125..127
          app/javascript/flavours/glitch/features/compose/index.jsx on lines 136..138
          app/javascript/mastodon/features/compose/index.jsx on lines 94..96
          app/javascript/mastodon/features/compose/index.jsx on lines 97..99
          app/javascript/mastodon/features/compose/index.jsx on lines 100..102
          app/javascript/mastodon/features/compose/index.jsx on lines 103..105

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

          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