mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

  handleBlockDomain = () => {
    const { status, onBlockDomain } = this.props;
    const account = status.get('account');

    onBlockDomain(account.get('acct').split('@')[1]);
Severity: Major
Found in app/javascript/mastodon/components/status_action_bar.js and 3 other locations - About 1 hr to fix
app/javascript/mastodon/components/status_action_bar.js on lines 200..205
app/javascript/mastodon/features/status/components/action_bar.js on lines 146..151
app/javascript/mastodon/features/status/components/action_bar.js on lines 153..158

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

  handleMoveDown = id => {
    const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1;
    this._selectChild(elementIndex, false);
  }
Severity: Major
Found in app/javascript/mastodon/features/notifications/index.js and 1 other location - About 1 hr to fix
app/javascript/mastodon/features/notifications/index.js on lines 148..151

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

  handleMoveUp = id => {
    const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1;
    this._selectChild(elementIndex, true);
  }
Severity: Major
Found in app/javascript/mastodon/features/notifications/index.js and 1 other location - About 1 hr to fix
app/javascript/mastodon/features/notifications/index.js on lines 153..156

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

            <div className='account-card__counters__item'>
              <ShortNumber value={account.get('followers_count')} />{' '}
              <small>
                <FormattedMessage
                  id='account.followers'
app/javascript/mastodon/features/directory/components/account_card.js on lines 208..216

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 2 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.js on lines 198..206

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

Function uploadCompose has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function uploadCompose(files) {
  return function (dispatch, getState) {
    const uploadLimit = 9;
    const media  = getState().getIn(['compose', 'media_attachments']);
    const pending  = getState().getIn(['compose', 'pending_media_attachments']);
Severity: Minor
Found in app/javascript/mastodon/actions/compose.js - About 1 hr to fix

    Function updateNotifications has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function updateNotifications(notification, intlMessages, intlLocale) {
      return (dispatch, getState) => {
        const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
        const showInColumn = activeFilter === 'all' ? getState().getIn(['settings', 'notifications', 'shows', notification.type], true) : activeFilter === notification.type;
        const showAlert    = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
    Severity: Minor
    Found in app/javascript/mastodon/actions/notifications.js - About 1 hr to fix

      Method deduplicate_users! has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def deduplicate_users!
            remove_index_if_exists!(:users, 'index_users_on_confirmation_token')
            remove_index_if_exists!(:users, 'index_users_on_email')
            remove_index_if_exists!(:users, 'index_users_on_remember_token')
            remove_index_if_exists!(:users, 'index_users_on_reset_password_token')
      Severity: Minor
      Found in lib/mastodon/maintenance_cli.rb - About 1 hr to fix

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

          render () {
            const { src, intl, alt, editable, autoPlay, sensitive, blurhash } = this.props;
            const { paused, muted, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
            const progress = Math.min((currentTime / duration) * 100, 100);
        
        
        Severity: Minor
        Found in app/javascript/mastodon/features/audio/index.js - About 1 hr 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 render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          render () {
            const { attachment, displayWidth } = this.props;
            const { visible, loaded } = this.state;
        
            const width  = `${Math.floor((displayWidth - 4) / 3) - 4}px`;

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

        export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
          const accessToken = getState().getIn(['meta', 'access_token'], '');
          const params      = _buildParams(getState());
        
          if (Object.keys(params).length === 0) {
        Severity: Minor
        Found in app/javascript/mastodon/actions/markers.js - About 1 hr 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 mapDispatchToProps has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        const mapDispatchToProps = (dispatch, { intl }) => ({
        
          onChange (path, checked) {
            if (path[0] === 'push') {
              if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {

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

          def safe_for_forwarding?(original, compacted)
            original.without('@context', 'signature').all? do |key, value|
              compacted_value = compacted[key]
              return false unless value.class == compacted_value.class
        
        
        Severity: Minor
        Found in app/helpers/jsonld_helper.rb - About 1 hr 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 process_attachments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_attachments
            return [] if @object['attachment'].nil?
        
            media_attachments = []
        
        
        Severity: Minor
        Found in app/lib/activitypub/activity/create.rb - About 1 hr 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 open has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def open(host, *args)
                outer_e = nil
                port    = args.first
        
                addresses = []
        Severity: Minor
        Found in app/lib/request.rb - About 1 hr 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 cc has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def cc(status)
            cc = []
        
            cc << uri_for(status.reblog.account) if status.reblog?
        
        
        Severity: Minor
        Found in app/lib/activitypub/tag_manager.rb - About 1 hr 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 process_remote_attachments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_remote_attachments
            # IMAGE: [https://s3.mashiro.top/view/2022/02/24/6f3f209aa55e3083f0659ecb62448fc0.jpg]
            image_array = @text.scan(/IMAGE:\s*\[\s*((?:https|http):\/\/.+?)\s*\](?:\s*\{\s*((?:https|http):\/\/.+?)\s*\})*/)
            video_array = @text.scan(/VIDEO:\s*\[\s*((?:https|http):\/\/.+?)\s*\](?:\s*\{\s*((?:https|http):\/\/.+?)\s*\})*/)
        
        
        Severity: Minor
        Found in app/services/post_status_service.rb - About 1 hr 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 parse_metadata has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def parse_metadata
            if @metadata.key?(:format)
              @duration = @metadata[:format][:duration].to_f
              @bitrate  = @metadata[:format][:bit_rate].to_i
            end
        Severity: Minor
        Found in app/lib/video_metadata_extractor.rb - About 1 hr 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 update_media_attachments! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_media_attachments!
            previous_media_attachments     = @status.media_attachments.to_a
            previous_media_attachments_ids = @status.ordered_media_attachment_ids || previous_media_attachments.map(&:id)
            next_media_attachments         = []
        
        
        Severity: Minor
        Found in app/services/activitypub/process_status_update_service.rb - About 1 hr 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 pluck_each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def pluck_each(*column_names)
              relation = self
        
              options = column_names.extract_options!
        
        
        Severity: Minor
        Found in lib/active_record/batches.rb - About 1 hr 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

        Severity
        Category
        Status
        Source
        Language