glitch-soc/mastodon

View on GitHub
app/javascript/flavours/glitch/features/directory/components/account_card.jsx

Summary

Maintainability
F
1 wk
Test Coverage

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

  render() {
    const { account, intl } = this.props;

    let actionBtn;

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

      render() {
        const { account, intl } = this.props;
    
        let actionBtn;
    
    

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

      onFollow(account) {
        if (account.getIn(['relationship', 'following'])) {
          dispatch(
            openModal({
              modalType: 'CONFIRM',

      Function mapDispatchToProps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const mapDispatchToProps = (dispatch, { intl }) => ({
        onFollow(account) {
          if (account.getIn(['relationship', 'following'])) {
            dispatch(
              openModal({

      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

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

          if (me !== account.get('id')) {
            if (!account.get('relationship')) { // Wait until the relationship is loaded
              actionBtn = '';
            } else if (account.getIn(['relationship', 'requested'])) {
              actionBtn = <Button  text={intl.formatMessage(messages.cancel_follow_request)} title={intl.formatMessage(messages.requested)} onClick={this.handleFollow} />;
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 151..165

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

      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 mapDispatchToProps = (dispatch, { intl }) => ({
        onFollow(account) {
          if (account.getIn(['relationship', 'following'])) {
            dispatch(
              openModal({
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 48..92

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

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

      const messages = defineMessages({
        unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
        follow: { id: 'account.follow', defaultMessage: 'Follow' },
        cancel_follow_request: { id: 'account.cancel_follow_request', defaultMessage: 'Withdraw follow request' },
        cancelFollowRequestConfirm: { id: 'confirmations.cancel_follow_request.confirm', defaultMessage: 'Withdraw request' },
      app/javascript/flavours/glitch/features/compose/components/poll_form.jsx on lines 20..31
      app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.jsx on lines 18..29
      app/javascript/flavours/glitch/features/compose/index.jsx on lines 39..50
      app/javascript/flavours/glitch/features/home_timeline/components/inline_follow_suggestions.jsx on lines 26..37
      app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx on lines 26..37
      app/javascript/flavours/glitch/features/report/category.jsx on lines 14..25
      app/javascript/mastodon/features/compose/components/poll_form.jsx on lines 19..30
      app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx on lines 18..29
      app/javascript/mastodon/features/compose/index.jsx on lines 36..47
      app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.jsx on lines 26..37
      app/javascript/mastodon/features/notifications/components/notification.jsx on lines 32..43
      app/javascript/mastodon/features/picture_in_picture/components/footer.jsx on lines 26..37

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

      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

              {account.get('note').length > 0 && (
                <div
                  className='account-card__bio translate'
                  onMouseEnter={this.handleMouseEnter}
                  onMouseLeave={this.handleMouseLeave}
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 185..192

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

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

                  <div className='account-card__counters__item'>
                    <ShortNumber value={account.get('following_count')} />{' '}
                    <small>
                      <FormattedMessage
                        id='account.following'
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 203..211
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 213..221

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

      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-card__counters__item'>
                    <ShortNumber value={account.get('statuses_count')} />
                    <small>
                      <FormattedMessage id='account.posts' defaultMessage='Posts' />
                    </small>
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 196..201

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

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

      const makeMapStateToProps = () => {
        const getAccount = makeGetAccount();
      
        const mapStateToProps = (state, { id }) => ({
          account: getAccount(state, id),
      app/javascript/flavours/glitch/components/inline_account.jsx on lines 9..17
      app/javascript/flavours/glitch/features/compose/containers/autosuggest_account_container.js on lines 6..14
      app/javascript/flavours/glitch/features/list_adder/components/account.jsx on lines 11..19
      app/javascript/flavours/glitch/features/ui/components/report_modal.jsx on lines 27..35
      app/javascript/mastodon/components/inline_account.jsx on lines 9..17
      app/javascript/mastodon/features/compose/containers/autosuggest_account_container.js on lines 6..14
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 38..46
      app/javascript/mastodon/features/list_adder/components/account.jsx on lines 11..19
      app/javascript/mastodon/features/ui/components/report_modal.jsx on lines 26..34

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

      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

              <Permalink href={account.get('url')} to={`/@${account.get('acct')}`} className='account-card__permalink'>
                <div className='account-card__header'>
                  {this.props.onDismiss && <IconButton className='media-modal__close' title={intl.formatMessage(messages.dismissSuggestion)} icon='times' onClick={this.handleDismiss} size={20} />}
      
                  <img
      app/javascript/flavours/glitch/features/compose/components/reply_indicator.jsx on lines 27..29
      app/javascript/flavours/glitch/features/compose/components/reply_indicator.jsx on lines 32..34
      app/javascript/flavours/glitch/features/follow_requests/components/account_authorize.jsx on lines 37..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 49.

      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

      There are no issues that match your filters.

      Category
      Status