glitch-soc/mastodon

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

Summary

Maintainability
F
1 wk
Test Coverage

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

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

    let actionBtn;

    Function render has a Cognitive Complexity of 13 (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({
      Severity: Minor
      Found in app/javascript/mastodon/features/directory/components/account_card.jsx - About 45 mins 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

      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/flavours/glitch/features/directory/components/account_card.jsx on lines 162..176

      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/flavours/glitch/features/directory/components/account_card.jsx on lines 50..94

      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 10 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/components/account.jsx on lines 23..33
      app/javascript/flavours/glitch/components/status_icons.jsx on lines 22..32
      app/javascript/flavours/glitch/features/direct_timeline/components/conversation.jsx on lines 32..42
      app/javascript/flavours/glitch/features/getting_started_misc/index.jsx on lines 21..31
      app/javascript/flavours/glitch/features/video/index.jsx on lines 27..37
      app/javascript/mastodon/components/account.jsx on lines 23..33
      app/javascript/mastodon/containers/status_container.jsx on lines 53..63
      app/javascript/mastodon/features/direct_timeline/components/conversation.jsx on lines 31..41
      app/javascript/mastodon/features/video/index.jsx on lines 27..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 156.

      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/flavours/glitch/features/directory/components/account_card.jsx on lines 198..205

      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('followers_count')} />{' '}
                    <small>
                      <FormattedMessage
                        id='account.followers'
      app/javascript/flavours/glitch/features/directory/components/account_card.jsx on lines 226..234
      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

      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/flavours/glitch/features/directory/components/account_card.jsx on lines 226..234
      app/javascript/mastodon/features/directory/components/account_card.jsx on lines 203..211

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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/flavours/glitch/features/directory/components/account_card.jsx on lines 209..214

      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/directory/components/account_card.jsx on lines 40..48
      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/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

      There are no issues that match your filters.

      Category
      Status