mashirozx/mastodon

View on GitHub
app/javascript/mastodon/features/filters/added_to_filter.js

Summary

Maintainability
C
1 day
Test Coverage

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

  render () {
    const { filter, contextType } = this.props;

    let expiredMessage = null;
    if (filter.get('expires_at') && filter.get('expires_at') < new Date()) {
Severity: Major
Found in app/javascript/mastodon/features/filters/added_to_filter.js - About 2 hrs to fix

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

        if (filter.get('expires_at') && filter.get('expires_at') < new Date()) {
          expiredMessage = (
            <React.Fragment>
              <h4 className='report-dialog-modal__subtitle'><FormattedMessage id='filter_modal.added.expired_title' defaultMessage='Expired filter!' /></h4>
              <p className='report-dialog-modal__lead'>
    Severity: Major
    Found in app/javascript/mastodon/features/filters/added_to_filter.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/filters/added_to_filter.js on lines 47..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 100.

    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

        if (contextType && !filter.get('context').includes(toServerSideType(contextType))) {
          contextMismatchMessage = (
            <React.Fragment>
              <h4 className='report-dialog-modal__subtitle'><FormattedMessage id='filter_modal.added.context_mismatch_title' defaultMessage='Context mismatch!' /></h4>
              <p className='report-dialog-modal__lead'>
    Severity: Major
    Found in app/javascript/mastodon/features/filters/added_to_filter.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/filters/added_to_filter.js on lines 32..44

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

    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='report-dialog-modal__actions'>
              <Button onClick={this.handleCloseClick}><FormattedMessage id='report.close' defaultMessage='Done' /></Button>
            </div>
    app/javascript/mastodon/features/report/statuses.js on lines 54..56
    app/javascript/mastodon/features/report/thanks.js on lines 77..79

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

    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

      static propTypes = {
        onClose: PropTypes.func.isRequired,
        contextType: PropTypes.string,
        filter: ImmutablePropTypes.map.isRequired,
        dispatch: PropTypes.func.isRequired,
    Severity: Major
    Found in app/javascript/mastodon/features/filters/added_to_filter.js and 3 other locations - About 55 mins to fix
    app/javascript/mastodon/features/account/components/account_note.js on lines 49..54
    app/javascript/mastodon/features/report/rules.js on lines 16..21
    app/javascript/mastodon/features/ui/components/filter_modal.js on lines 20..25

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

            <p className='report-dialog-modal__lead'>
              <FormattedMessage
                id='filter_modal.added.review_and_configure'
                defaultMessage='To review and further configure this filter category, go to the {settings_link}.'
                values={{ settings_link }}
    Severity: Minor
    Found in app/javascript/mastodon/features/filters/added_to_filter.js and 2 other locations - About 40 mins to fix
    app/javascript/mastodon/components/autosuggest_hashtag.js on lines 30..36
    app/javascript/mastodon/features/follow_requests/index.js on lines 65..71

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

    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