glitch-soc/mastodon

View on GitHub

Showing 4,906 of 4,906 total issues

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

const filterNotificationsByAllowedTypes = (
  showFilterBar: boolean,
  allowedType: string,
  excludedTypes: string[],
  notifications: (NotificationGroup | NotificationGap)[],
Severity: Major
Found in app/javascript/mastodon/selectors/notifications.ts and 1 other location - About 5 hrs to fix
app/javascript/flavours/glitch/selectors/notifications.ts on lines 14..31

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

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 ShortNumberRenderer: React.FC<ShortNumberProps> = ({
  value,
  renderer,
  children,
}) => {
Severity: Major
Found in app/javascript/flavours/glitch/components/short_number.tsx and 1 other location - About 5 hrs to fix
app/javascript/mastodon/components/short_number.tsx on lines 19..41

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

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 favouriteLink = (
    <Link
      to={`/@${status.getIn(['account', 'acct'])}/${status.get('id')}/favourites`}
      className='detailed-status__link'
    >
app/javascript/mastodon/features/status/components/detailed_status.tsx on lines 276..290

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

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 filterNotificationsByAllowedTypes = (
  showFilterBar: boolean,
  allowedType: string,
  excludedTypes: string[],
  notifications: (NotificationGroup | NotificationGap)[],
Severity: Major
Found in app/javascript/flavours/glitch/selectors/notifications.ts and 1 other location - About 5 hrs to fix
app/javascript/mastodon/selectors/notifications.ts on lines 14..31

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

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

Video has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

class Video extends PureComponent {

  static propTypes = {
    preview: PropTypes.string,
    frameRate: PropTypes.string,
Severity: Minor
Found in app/javascript/flavours/glitch/features/video/index.jsx - About 5 hrs to fix

    Video has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Video extends PureComponent {
    
      static propTypes = {
        preview: PropTypes.string,
        frameRate: PropTypes.string,
    Severity: Minor
    Found in app/javascript/mastodon/features/video/index.jsx - About 5 hrs to fix

      Class Create has 40 methods (exceeds 20 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 5 hrs to fix

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

                <div className='account--panel'>
                  <div className='account--panel__button'><IconButton title={intl.formatMessage(messages.authorize)} icon='check' iconComponent={CheckIcon} onClick={onAuthorize} /></div>
                  <div className='account--panel__button'><IconButton title={intl.formatMessage(messages.reject)} icon='times' iconComponent={CloseIcon} onClick={onReject} /></div>
                </div>
        app/javascript/mastodon/features/follow_requests/components/account_authorize.jsx on lines 46..49

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

        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 4 locations. Consider refactoring.
        Open

          handleMouseDown = e => {
            document.addEventListener('mousemove', this.handleMouseMove, true);
            document.addEventListener('mouseup', this.handleMouseUp, true);
            document.addEventListener('touchmove', this.handleMouseMove, true);
            document.addEventListener('touchend', this.handleMouseUp, true);
        Severity: Major
        Found in app/javascript/flavours/glitch/features/audio/index.jsx and 3 other locations - About 5 hrs to fix
        app/javascript/flavours/glitch/features/video/index.jsx on lines 239..251
        app/javascript/mastodon/features/audio/index.jsx on lines 250..262
        app/javascript/mastodon/features/video/index.jsx on lines 236..248

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

        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 4 locations. Consider refactoring.
        Open

          handleMouseDown = e => {
            document.addEventListener('mousemove', this.handleMouseMove, true);
            document.addEventListener('mouseup', this.handleMouseUp, true);
            document.addEventListener('touchmove', this.handleMouseMove, true);
            document.addEventListener('touchend', this.handleMouseUp, true);
        Severity: Major
        Found in app/javascript/mastodon/features/audio/index.jsx and 3 other locations - About 5 hrs to fix
        app/javascript/flavours/glitch/features/audio/index.jsx on lines 256..268
        app/javascript/flavours/glitch/features/video/index.jsx on lines 239..251
        app/javascript/mastodon/features/video/index.jsx on lines 236..248

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

        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

                <div className='account--panel'>
                  <div className='account--panel__button'><IconButton title={intl.formatMessage(messages.authorize)} icon='check' iconComponent={CheckIcon} onClick={onAuthorize} /></div>
                  <div className='account--panel__button'><IconButton title={intl.formatMessage(messages.reject)} icon='times' iconComponent={CloseIcon} onClick={onReject} /></div>
                </div>
        app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.jsx on lines 45..48

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

        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 4 locations. Consider refactoring.
        Open

          handleMouseDown = e => {
            document.addEventListener('mousemove', this.handleMouseMove, true);
            document.addEventListener('mouseup', this.handleMouseUp, true);
            document.addEventListener('touchmove', this.handleMouseMove, true);
            document.addEventListener('touchend', this.handleMouseUp, true);
        Severity: Major
        Found in app/javascript/flavours/glitch/features/video/index.jsx and 3 other locations - About 5 hrs to fix
        app/javascript/flavours/glitch/features/audio/index.jsx on lines 256..268
        app/javascript/mastodon/features/audio/index.jsx on lines 250..262
        app/javascript/mastodon/features/video/index.jsx on lines 236..248

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

        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 addAutoPlay = html => {
          const document = domParser.parseFromString(html, 'text/html').documentElement;
          const iframe = document.querySelector('iframe');
        
          if (iframe) {
        Severity: Major
        Found in app/javascript/mastodon/features/status/components/card.jsx and 1 other location - About 5 hrs to fix
        app/javascript/flavours/glitch/features/status/components/card.jsx on lines 29..48

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

        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 4 locations. Consider refactoring.
        Open

          handleMouseDown = e => {
            document.addEventListener('mousemove', this.handleMouseMove, true);
            document.addEventListener('mouseup', this.handleMouseUp, true);
            document.addEventListener('touchmove', this.handleMouseMove, true);
            document.addEventListener('touchend', this.handleMouseUp, true);
        Severity: Major
        Found in app/javascript/mastodon/features/video/index.jsx and 3 other locations - About 5 hrs to fix
        app/javascript/flavours/glitch/features/audio/index.jsx on lines 256..268
        app/javascript/flavours/glitch/features/video/index.jsx on lines 239..251
        app/javascript/mastodon/features/audio/index.jsx on lines 250..262

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

        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 addAutoPlay = html => {
          const document = domParser.parseFromString(html, 'text/html').documentElement;
          const iframe = document.querySelector('iframe');
        
          if (iframe) {
        app/javascript/mastodon/features/status/components/card.jsx on lines 40..59

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

        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 render has 132 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render () {
            const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;
            const { signedIn, permissions } = this.props.identity;
        
            const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
        Severity: Major
        Found in app/javascript/mastodon/components/status_action_bar.jsx - About 5 hrs to fix

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

            render () {
              const { intl, hidden, featured, unfocusable, unread, showThread, scrollKey, pictureInPicture, previousId, nextInReplyToId, rootId, skipPrepend, avatarSize = 46 } = this.props;
          
              let { status, account, ...other } = this.props;
          
          
          Severity: Minor
          Found in app/javascript/mastodon/components/status.jsx - About 5 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 remove_files has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def remove_files
              keys = []
          
              logger.debug { "Preparing to delete attachments for #{records.size} records" }
          
          
          Severity: Minor
          Found in app/lib/attachment_batch.rb - About 5 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

          Function EmbeddedStatus has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          export const EmbeddedStatus: React.FC<{ statusId: string }> = ({
            statusId,
          }) => {
            const history = useHistory();
            const clickCoordinatesRef = useRef<[number, number] | null>();

          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 5 locations. Consider refactoring.
          Open

          const messages = defineMessages({
            reply: { id: 'status.reply', defaultMessage: 'Reply' },
            replyAll: { id: 'status.replyAll', defaultMessage: 'Reply to thread' },
            reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
            reblog_private: { id: 'status.reblog_private', defaultMessage: 'Boost with original visibility' },
          app/javascript/flavours/glitch/features/compose/index.jsx on lines 34..43
          app/javascript/flavours/glitch/features/getting_started_misc/index.jsx on lines 19..28
          app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx on lines 28..37
          app/javascript/mastodon/features/compose/index.jsx on lines 31..40

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

          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