glitch-soc/mastodon

View on GitHub

Showing 4,906 of 4,906 total issues

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

  render () {
    const { card } = this.props;
    const { embedded, revealed } = this.state;

    if (card === null) {
Severity: Major
Found in app/javascript/flavours/glitch/features/status/components/card.jsx - About 4 hrs to fix

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

      render () {
        const { card } = this.props;
        const { embedded, revealed } = this.state;
    
        if (card === null) {
    Severity: Major
    Found in app/javascript/mastodon/features/status/components/card.jsx - About 4 hrs to fix

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

      Comment.propTypes = {
        comment: PropTypes.string.isRequired,
        domain: PropTypes.string,
        statusIds: ImmutablePropTypes.list.isRequired,
        isRemote: PropTypes.bool,
      Severity: Major
      Found in app/javascript/mastodon/features/report/comment.jsx and 1 other location - About 4 hrs to fix
      app/javascript/flavours/glitch/features/report/comment.jsx on lines 109..119

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

      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_SPOILERNESS_CHANGE:
          return state.withMutations(map => {
            map.set('spoiler', !state.get('spoiler'));
            map.set('idempotencyKey', uuid());
      
      
      Severity: Major
      Found in app/javascript/mastodon/reducers/compose.js and 1 other location - About 4 hrs to fix
      app/javascript/flavours/glitch/reducers/compose.js on lines 395..403

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

      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

      Comment.propTypes = {
        comment: PropTypes.string.isRequired,
        domain: PropTypes.string,
        statusIds: ImmutablePropTypes.list.isRequired,
        isRemote: PropTypes.bool,
      Severity: Major
      Found in app/javascript/flavours/glitch/features/report/comment.jsx and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/features/report/comment.jsx on lines 109..119

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

      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_SPOILERNESS_CHANGE:
          return state.withMutations(map => {
            map.set('spoiler', !state.get('spoiler'));
            map.set('idempotencyKey', uuid());
      
      
      Severity: Major
      Found in app/javascript/flavours/glitch/reducers/compose.js and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/reducers/compose.js on lines 315..323

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

      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

                <div ref={this.handleRef} className={classNames('status__wrapper', { focusable: !this.props.muted })} tabIndex={unfocusable ? null : 0}>
                  <span>{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}</span>
                  {status.get('spoiler_text').length > 0 && (<span>{status.get('spoiler_text')}</span>)}
                  {expanded && <span>{status.get('content')}</span>}
                </div>
      Severity: Major
      Found in app/javascript/mastodon/components/status.jsx and 1 other location - About 4 hrs to fix
      app/javascript/flavours/glitch/components/status.jsx on lines 488..492

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

      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

        handleMouseVolSlide = throttle(e => {
          const { x } = getPointerPosition(this.volume, e);
      
          if(!isNaN(x)) {
            this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
      Severity: Major
      Found in app/javascript/mastodon/features/video/index.jsx and 1 other location - About 4 hrs to fix
      app/javascript/flavours/glitch/features/video/index.jsx on lines 228..237

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

      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

                <div ref={this.handleRef} className='status focusable' tabIndex={unfocusable ? null : 0}>
                  <span>{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}</span>
                  {status.get('spoiler_text').length > 0 && (<span>{status.get('spoiler_text')}</span>)}
                  {expanded && <span>{status.get('content')}</span>}
                </div>
      Severity: Major
      Found in app/javascript/flavours/glitch/components/status.jsx and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/components/status.jsx on lines 435..439

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

      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

        handleMouseVolSlide = throttle(e => {
          const { x } = getPointerPosition(this.volume, e);
      
          if(!isNaN(x)) {
            this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
      Severity: Major
      Found in app/javascript/flavours/glitch/features/video/index.jsx and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/features/video/index.jsx on lines 225..234

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

      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 loaded() {
        const mountNode = document.getElementById('mastodon-status');
      
        if (mountNode) {
          const attr = mountNode.getAttribute('data-props');
      Severity: Major
      Found in app/javascript/flavours/glitch/entrypoints/embed.tsx and 1 other location - About 4 hrs to fix
      app/javascript/entrypoints/embed.tsx on lines 13..26

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

      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 loaded() {
        const mountNode = document.getElementById('mastodon-status');
      
        if (mountNode) {
          const attr = mountNode.getAttribute('data-props');
      Severity: Major
      Found in app/javascript/entrypoints/embed.tsx and 1 other location - About 4 hrs to fix
      app/javascript/flavours/glitch/entrypoints/embed.tsx on lines 13..26

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

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

      function getData(emoji, skin, set) {
        let emojiData = {};
      
        if (typeof emoji === 'string') {
          let matches = emoji.match(COLONS_REGEX);
      Severity: Minor
      Found in app/javascript/flavours/glitch/features/emoji/emoji_utils.js - About 4 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 getData has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      function getData(emoji, skin, set) {
        let emojiData = {};
      
        if (typeof emoji === 'string') {
          let matches = emoji.match(COLONS_REGEX);
      Severity: Minor
      Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 4 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 AccountCard has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      export const AccountCard: React.FC<{ accountId: string }> = ({ accountId }) => {
        const intl = useIntl();
        const account = useAppSelector((s) => getAccount(s, accountId));
        const dispatch = useAppDispatch();
      
      

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

      }> = ({ accountId }) => {
        const intl = useIntl();
        const dispatch = useAppDispatch();
        const { signedIn } = useIdentity();
        const account = useAppSelector((state) =>
      Severity: Minor
      Found in app/javascript/mastodon/components/follow_button.tsx - About 4 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 AccountCard has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      export const AccountCard: React.FC<{ accountId: string }> = ({ accountId }) => {
        const intl = useIntl();
        const account = useAppSelector((s) => getAccount(s, accountId));
        const dispatch = useAppDispatch();
      
      

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

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

        Function notificationRequestsReducer has 102 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          createReducer<NotificationRequestsState>(initialState, (builder) => {
            builder
              .addCase(fetchNotificationRequests.fulfilled, (state, action) => {
                state.items = action.payload.requests
                  .map(createNotificationRequestFromJSON)
        Severity: Major
        Found in app/javascript/flavours/glitch/reducers/notification_requests.ts - About 4 hrs to fix

          Function notificationRequestsReducer has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createReducer<NotificationRequestsState>(initialState, (builder) => {
              builder
                .addCase(fetchNotificationRequests.fulfilled, (state, action) => {
                  state.items = action.payload.requests
                    .map(createNotificationRequestFromJSON)
          Severity: Major
          Found in app/javascript/mastodon/reducers/notification_requests.ts - About 4 hrs to fix
            Severity
            Category
            Status
            Source
            Language