mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

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

              def scan_text!
                @status.text = @status.text.gsub(Account::MENTION_RE) do |match|
                  username, domain = Regexp.last_match(1).split('@')
            
                  domain = begin
            Severity: Minor
            Found in app/services/process_mentions_service.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 link_to_mention has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def link_to_mention(entity)
                username, domain = entity[:screen_name].split('@')
                domain           = nil if local_domain?(domain)
                account          = nil
            
            
            Severity: Minor
            Found in app/lib/text_formatter.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 setup_redis_env_url has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            def setup_redis_env_url(prefix = nil, defaults = true)
              prefix = prefix.to_s.upcase + '_' unless prefix.nil?
              prefix = '' if prefix.nil?
            
              return if ENV[prefix + 'REDIS_URL'].present?
            Severity: Minor
            Found in lib/mastodon/redis_config.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 refresh has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def refresh(username = nil)
                  dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
            
                  if options[:domain] || options[:all]
                    scope  = Account.remote
            Severity: Minor
            Found in lib/mastodon/accounts_cli.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 purge has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def purge(*domains)
                  dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
            
                  scope = begin
                    if options[:limited_federation_mode]
            Severity: Minor
            Found in lib/mastodon/domains_cli.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 perform has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def perform
                # Maintaining a materialized view speeds-up subsequent queries significantly
                AccountSummary.refresh
                FollowRecommendation.refresh
            
            
            Severity: Minor
            Found in app/workers/scheduler/follow_recommendations_scheduler.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

            Function renderItem has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              renderItem (account, size, index) {
                const { animate } = this.props;
            
                let width  = 50;
                let height = 100;
            Severity: Major
            Found in app/javascript/mastodon/components/avatar_composite.js - About 2 hrs to fix

              Function statuses has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function statuses(state = initialState, action) {
                switch(action.type) {
                case STATUS_IMPORT:
                  return importStatus(state, action.status);
                case STATUSES_IMPORT:
              Severity: Major
              Found in app/javascript/mastodon/reducers/statuses.js - About 2 hrs to fix

                Method from_elasticsearch has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def from_elasticsearch
                    query = {
                      function_score: {
                        query: {
                          multi_match: {
                Severity: Major
                Found in app/services/tag_search_service.rb - About 2 hrs to fix

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

                    render () {
                      const { attachments, isLoading, hasMore, isAccount, multiColumn, blockedBy, suspended } = this.props;
                      const { width } = this.state;
                  
                      if (!isAccount) {
                  Severity: Major
                  Found in app/javascript/mastodon/features/account_gallery/index.js - About 2 hrs to fix

                    Function listEditorReducer has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function listEditorReducer(state = initialState, action) {
                      switch(action.type) {
                      case LIST_EDITOR_RESET:
                        return initialState;
                      case LIST_EDITOR_SETUP:
                    Severity: Major
                    Found in app/javascript/mastodon/reducers/list_editor.js - About 2 hrs to fix

                      ActionBar has 21 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export default @connect(mapStateToProps)
                      @injectIntl
                      class ActionBar extends React.PureComponent {
                      
                        static contextTypes = {
                      Severity: Minor
                      Found in app/javascript/mastodon/features/status/components/action_bar.js - About 2 hrs to fix

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

                        class AccountsController < ApplicationController
                          PAGE_SIZE     = 20
                          PAGE_SIZE_MAX = 200
                        
                          include AccountControllerConcern
                        Severity: Minor
                        Found in app/controllers/accounts_controller.rb - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language