mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

Function renderOption has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderOption (option, optionIndex, showResults) {
    const { poll, disabled, intl } = this.props;
    const pollVotesCount  = poll.get('voters_count') || poll.get('votes_count');
    const percent         = pollVotesCount === 0 ? 0 : (option.get('votes_count') / pollVotesCount) * 100;
    const leading         = poll.get('options').filterNot(other => other.get('title') === option.get('title')).every(other => option.get('votes_count') >= other.get('votes_count'));
Severity: Major
Found in app/javascript/mastodon/components/poll.js - About 2 hrs to fix

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

      handleModalActionClick = (e) => {
        e.preventDefault();
    
        const { value } = this.options[e.currentTarget.getAttribute('data-index')];
    
    
    app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 183..190
    app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 191..198

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

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

      handleModalActionClick = (e) => {
        e.preventDefault();
    
        const { value } = this.options[e.currentTarget.getAttribute('data-index')];
    
    
    app/javascript/mastodon/features/compose/components/content_type_dropdown.js on lines 183..190
    app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 183..190

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

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

      handleModalActionClick = (e) => {
        e.preventDefault();
    
        const { value } = this.options[e.currentTarget.getAttribute('data-index')];
    
    
    app/javascript/mastodon/features/compose/components/content_type_dropdown.js on lines 183..190
    app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 191..198

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

    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

      onNotifyToggle (account) {
        if (account.getIn(['relationship', 'notifying'])) {
          dispatch(followAccount(account.get('id'), { notify: false }));
        } else {
          dispatch(followAccount(account.get('id'), { notify: true }));
    app/javascript/mastodon/features/account_timeline/containers/header_container.js on lines 76..82

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

    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 (status.get('media_attachments').size > 0) {
          if (pictureInPicture.get('inUse')) {
            media = <PictureInPicturePlaceholder width={this.props.cachedMediaWidth} />;
          } else if (this.props.muted) {
            media = <AttachmentList compact media={status.get('media_attachments')} />;
    app/javascript/mastodon/features/status/components/detailed_status.js on lines 164..217

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

    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

      onReblogToggle (account) {
        if (account.getIn(['relationship', 'showing_reblogs'])) {
          dispatch(followAccount(account.get('id'), { reblogs: false }));
        } else {
          dispatch(followAccount(account.get('id'), { reblogs: true }));
    app/javascript/mastodon/features/account_timeline/containers/header_container.js on lines 92..98

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

    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 (this.state.paused) {
          this.setState({ paused: false }, () => this.audio.play());
        } else {
          this.setState({ paused: true }, () => this.audio.pause());
        }
    Severity: Major
    Found in app/javascript/mastodon/features/audio/index.js and 1 other location - About 2 hrs to fix
    app/javascript/mastodon/features/video/index.js on lines 352..356

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

    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 (quote_status.get('media_attachments').size > 0) {
    
            if (quote_status.getIn(['media_attachments', 0, 'type']) === 'audio') {
              const attachment = quote_status.getIn(['media_attachments', 0]);
    
    
    app/javascript/mastodon/features/status/components/detailed_status.js on lines 232..290

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

    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 (this.state.paused) {
          this.setState({ paused: false }, () => this.video.play());
        } else {
          this.setState({ paused: true }, () => this.video.pause());
        }
    Severity: Major
    Found in app/javascript/mastodon/features/video/index.js and 1 other location - About 2 hrs to fix
    app/javascript/mastodon/features/audio/index.js on lines 160..164

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

    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 media_cli.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative '../../config/boot'
    require_relative '../../config/environment'
    require_relative 'cli_helper'
    
    module Mastodon
    Severity: Minor
    Found in lib/mastodon/media_cli.rb - About 2 hrs to fix

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

        render () {
          const { status, width, height } = this.props;
          const mediaAttachments = status.get('media_attachments');
      
          if (mediaAttachments.size === 0) {
      Severity: Major
      Found in app/javascript/mastodon/components/media_attachments.js - About 2 hrs to fix

        Class AccountAction has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Admin::AccountAction
          include ActiveModel::Model
          include AccountableConcern
          include Authorization
        
        
        Severity: Minor
        Found in app/models/admin/account_action.rb - About 2 hrs to fix

          Class AccountsController has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Api::V1::Admin::AccountsController < Api::BaseController
            include Authorization
            include AccountableConcern
          
            LIMIT = 100
          Severity: Minor
          Found in app/controllers/api/v1/admin/accounts_controller.rb - About 2 hrs to fix

            Class AccountsController has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class AccountsController < BaseController
                before_action :set_account, except: [:index, :batch]
                before_action :require_remote_account!, only: [:redownload]
                before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
            
            
            Severity: Minor
            Found in app/controllers/admin/accounts_controller.rb - About 2 hrs to fix

              Class ApplicationController has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class ApplicationController < ActionController::Base
                # Prevent CSRF attacks by raising an exception.
                # For APIs, you may want to use :null_session instead.
                protect_from_forgery with: :exception
              
              
              Severity: Minor
              Found in app/controllers/application_controller.rb - About 2 hrs to fix

                Class AccountStatusesFilter has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class AccountStatusesFilter
                  KEYS = %i(
                    pinned
                    tagged
                    only_media
                Severity: Minor
                Found in app/models/account_statuses_filter.rb - About 2 hrs to fix

                  Class AccountSearchService has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class AccountSearchService < BaseService
                    attr_reader :query, :limit, :offset, :options, :account
                  
                    def call(query, account = nil, options = {})
                      @acct_hint = query&.start_with?('@')
                  Severity: Minor
                  Found in app/services/account_search_service.rb - About 2 hrs to fix

                    Method pam_get_user has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.pam_get_user(attributes = {})
                          return nil unless attributes[:email]
                    
                          resource = begin
                            if Devise.check_at_sign && !attributes[:email].index('@')
                    Severity: Minor
                    Found in app/models/concerns/pam_authenticable.rb - About 2 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

                    Method index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def index
                        respond_to do |format|
                          format.html do
                            expires_in 0, public: true unless user_signed_in?
                    
                    
                    Severity: Minor
                    Found in app/controllers/following_accounts_controller.rb - About 2 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

                    Severity
                    Category
                    Status
                    Source
                    Language