mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

      if (relationship && relationship.get('blocking')) {
        menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
      } else {
        menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick });
      }
Severity: Major
Found in app/javascript/mastodon/components/status_action_bar.js and 3 other locations - About 4 hrs to fix
app/javascript/mastodon/components/status_action_bar.js on lines 295..299
app/javascript/mastodon/features/status/components/action_bar.js on lines 235..239
app/javascript/mastodon/features/status/components/action_bar.js on lines 241..245

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

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

      if (relationship && relationship.get('blocking')) {
        menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
      } else {
        menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick });
      }
app/javascript/mastodon/components/status_action_bar.js on lines 295..299
app/javascript/mastodon/components/status_action_bar.js on lines 301..305
app/javascript/mastodon/features/status/components/action_bar.js on lines 235..239

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

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

      if (relationship && relationship.get('muting')) {
        menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
      } else {
        menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick });
      }
Severity: Major
Found in app/javascript/mastodon/components/status_action_bar.js and 3 other locations - About 4 hrs to fix
app/javascript/mastodon/components/status_action_bar.js on lines 301..305
app/javascript/mastodon/features/status/components/action_bar.js on lines 235..239
app/javascript/mastodon/features/status/components/action_bar.js on lines 241..245

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

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

      if (relationship && relationship.get('muting')) {
        menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
      } else {
        menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick });
      }
app/javascript/mastodon/components/status_action_bar.js on lines 295..299
app/javascript/mastodon/components/status_action_bar.js on lines 301..305
app/javascript/mastodon/features/status/components/action_bar.js on lines 241..245

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

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

UI has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

export default @connect(mapStateToProps)
@injectIntl
@withRouter
class UI extends React.PureComponent {

Severity: Minor
Found in app/javascript/mastodon/features/ui/index.js - About 4 hrs to fix

    File zoomable_image.js has 361 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import PropTypes from 'prop-types';
    import IconButton from 'mastodon/components/icon_button';
    import { defineMessages, injectIntl } from 'react-intl';
    
    
    Severity: Minor
    Found in app/javascript/mastodon/features/ui/components/zoomable_image.js - About 4 hrs to fix

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

      export function fetchReblogs(id) {
        return (dispatch, getState) => {
          dispatch(fetchReblogsRequest(id));
      
          api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => {
      Severity: Major
      Found in app/javascript/mastodon/actions/interactions.js and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/actions/interactions.js on lines 305..316

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

      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

      export function fetchFavourites(id) {
        return (dispatch, getState) => {
          dispatch(fetchFavouritesRequest(id));
      
          api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => {
      Severity: Major
      Found in app/javascript/mastodon/actions/interactions.js and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/actions/interactions.js on lines 270..281

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

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

        render () {
          const { media, intl, account, onClose, isUploadingThumbnail, description, focusX, focusY, dirty, is_changing_upload } = this.props;
          const { dragging, detecting, progress, ocrStatus } = this.state;
          const x = (focusX /  2) + .5;
          const y = (focusY / -2) + .5;
      Severity: Major
      Found in app/javascript/mastodon/features/ui/components/focal_point_modal.js - About 4 hrs to fix

        Function listener has 115 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const listener = message => {
              const json = parseJSON(message, req);
        
              if (!json) return;
        
        
        Severity: Major
        Found in streaming/index.js - About 4 hrs to fix

          Method crawl has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              def crawl(start = nil)
                stats           = Concurrent::Hash.new
                processed       = Concurrent::AtomicFixnum.new(0)
                failed          = Concurrent::AtomicFixnum.new(0)
                start_at        = Time.now.to_f
          Severity: Minor
          Found in lib/mastodon/domains_cli.rb - 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 translationEndpointCallback has 114 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const translationEndpointCallback = async (request, response) => {
            const body = request.body;
          
            const { content, to, status, edit } = body;
          
          
          Severity: Major
          Found in translation/index.js - About 4 hrs to fix

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

              render () {
                const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, detailed, sensitive, editable, blurhash } = this.props;
                const { quote } = this.props;
                // const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, detailed, sensitive, link, editable, blurhash, quote } = this.props;
                const { containerWidth, currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, muted, revealed } = this.state;
            Severity: Major
            Found in app/javascript/mastodon/features/video/index.js - About 4 hrs to fix

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

                  if (this.props.isUserTouching()) {
                    if (this.state.open) {
                      this.props.onModalClose();
                    } else {
                      this.props.onModalOpen({
              app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 172..188

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

              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

                  if (this.props.isUserTouching && this.props.isUserTouching()) {
                    if (this.state.open) {
                      this.props.onModalClose();
                    } else {
                      this.props.onModalOpen({
              app/javascript/mastodon/features/compose/components/content_type_dropdown.js on lines 164..180

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

              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 mapStateToProps = (state, { columnId }) => {
                const uuid = columnId;
                const columns = state.getIn(['settings', 'columns']);
                const index = columns.findIndex(c => c.get('uuid') === uuid);
              
              
              app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js on lines 6..14

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

              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 mapStateToProps = (state, { columnId }) => {
                const uuid = columnId;
                const columns = state.getIn(['settings', 'columns']);
                const index = columns.findIndex(c => c.get('uuid') === uuid);
              
              
              app/javascript/mastodon/features/community_timeline/containers/column_settings_container.js on lines 6..14

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

              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

                api(getState).get('/api/v1/trends/statuses').then(response => {
                  const next = getLinks(response).refs.find(link => link.rel === 'next');
                  dispatch(importFetchedStatuses(response.data));
                  dispatch(fetchTrendingStatusesSuccess(response.data, next ? next.uri : null));
                }).catch(err => dispatch(fetchTrendingStatusesFail(err)));
              Severity: Major
              Found in app/javascript/mastodon/actions/trends.js and 1 other location - About 4 hrs to fix
              app/javascript/mastodon/actions/accounts.js on lines 585..589

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

              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

                  api(getState).get('/api/v1/follow_requests').then(response => {
                    const next = getLinks(response).refs.find(link => link.rel === 'next');
                    dispatch(importFetchedAccounts(response.data));
                    dispatch(fetchFollowRequestsSuccess(response.data, next ? next.uri : null));
                  }).catch(error => dispatch(fetchFollowRequestsFail(error)));
              Severity: Major
              Found in app/javascript/mastodon/actions/accounts.js and 1 other location - About 4 hrs to fix
              app/javascript/mastodon/actions/trends.js on lines 81..85

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

              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

              File user.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class User < ApplicationRecord
                self.ignored_columns = %w(
                  remember_created_at
                  remember_token
                  current_sign_in_ip
              Severity: Minor
              Found in app/models/user.rb - About 4 hrs to fix
                Severity
                Category
                Status
                Source
                Language