mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Consider simplifying this complex logical expression.
Open

    } else if (isLoading || childrenCount > 0 || numPending > 0 || hasMore || !emptyMessage) {
      scrollableArea = (
        <div className={classNames('scrollable', { fullscreen })} ref={this.setRef} onMouseMove={this.handleMouseMove}>
          <div role='feed' className='item-list'>
            {prepend}
Severity: Major
Found in app/javascript/mastodon/components/scrollable_list.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if current_account_id.nil?
          @reblogs_map    = {}
          @favourites_map = {}
          @bookmarks_map  = {}
          @mutes_map      = {}
    Severity: Major
    Found in app/presenters/status_relationships_presenter.rb - About 1 hr to fix

      Function stringFromCodePoint has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const stringFromCodePoint = _String.fromCodePoint || function () {
        let MAX_SIZE = 0x4000;
        let codeUnits = [];
        let highSurrogate;
        let lowSurrogate;
      Severity: Minor
      Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 55 mins 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 handleNotificationClick has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const handleNotificationClick = (event) => {
        const reactToNotificationClick = new Promise((resolve, reject) => {
          if (event.action) {
            if (event.action === 'expand') {
              resolve(expandNotification(event.notification));
      Severity: Minor
      Found in app/javascript/mastodon/service_worker/web_push_notifications.js - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

        render () {
          const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, emptyMessage, onLoadMore } = this.props;
          const { fullscreen } = this.state;
          const childrenCount = React.Children.count(children);
      
      
      Severity: Minor
      Found in app/javascript/mastodon/components/scrollable_list.js - About 55 mins 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 statuses has a Cognitive Complexity of 9 (exceeds 5 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: Minor
      Found in app/javascript/mastodon/reducers/statuses.js - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

        render () {
          const { media, statusId, intl, onClose } = this.props;
          const { navigationHidden } = this.state;
      
          const index = this.getIndex();
      Severity: Minor
      Found in app/javascript/mastodon/features/ui/components/media_modal.js - About 55 mins 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 stricter_than? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def stricter_than?(other_block)
          return true  if suspend?
          return false if other_block.suspend? && (silence? || noop?)
          return false if other_block.silence? && noop?
      
      
      Severity: Minor
      Found in app/models/domain_block.rb - About 55 mins 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 destroy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def destroy
              credential = current_user.webauthn_credentials.find_by(id: params[:id])
              if credential
                credential.destroy
                if credential.destroyed?

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

          def preload_cache_collection_target_statuses(notifications, &_block)
            notifications.group_by(&:type).each do |type, grouped_notifications|
              associations = TARGET_STATUS_INCLUDES_BY_TYPE[type]
              next unless associations
      
      
      Severity: Minor
      Found in app/models/notification.rb - About 55 mins 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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def get(limit, max_id = nil, since_id = nil, min_id = nil)
          return [] if account_is_bot?
      
          scope = public_scope
      
      
      Severity: Minor
      Found in app/models/public_feed.rb - About 55 mins 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def create
              webauthn_credential = WebAuthn::Credential.from_create(params[:credential])
      
              if webauthn_credential.verify(session[:webauthn_challenge])
                user_credential = current_user.webauthn_credentials.build(

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

        def self.provides_callback_for(provider)
          provider_id = provider.to_s.chomp '_oauth2'
      
          define_method provider do
            @user = User.find_for_oauth(request.env['omniauth.auth'], current_user)
      Severity: Minor
      Found in app/controllers/auth/omniauth_callbacks_controller.rb - About 55 mins 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 rss_status_content_format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def rss_status_content_format(status)
          html = status_content_format(status)
      
          before_html = begin
            if status.spoiler_text?
      Severity: Minor
      Found in app/helpers/formatting_helper.rb - About 55 mins 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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          unless ENV['TRANSLATION_SERVER_HOST']
            render json: { 'message' => 'TRANSLATION_SERVER_HOST not found in ENV'}, status:400
            return
          end
      Severity: Minor
      Found in app/controllers/translation_controller.rb - About 55 mins 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 request_follow! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def request_follow!(other_account, reblogs: nil, notify: nil, uri: nil, rate_limit: false, bypass_limit: false)
          rel = follow_requests.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
                               .find_or_create_by!(target_account: other_account)
      
          rel.show_reblogs = reblogs unless reblogs.nil?
      Severity: Minor
      Found in app/models/concerns/account_interactions.rb - About 55 mins 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 relevant_account_timestamp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def relevant_account_timestamp(account)
          timestamp, exact = begin
            if account.user_current_sign_in_at && account.user_current_sign_in_at < 24.hours.ago
              [account.user_current_sign_in_at, true]
            elsif account.user_current_sign_in_at
      Severity: Minor
      Found in app/helpers/admin/dashboard_helper.rb - About 55 mins 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 follow! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def follow!(other_account, reblogs: nil, notify: nil, uri: nil, rate_limit: false, bypass_limit: false)
          rel = active_relationships.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
                                    .find_or_create_by!(target_account: other_account)
      
          rel.show_reblogs = reblogs unless reblogs.nil?
      Severity: Minor
      Found in app/models/concerns/account_interactions.rb - About 55 mins 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 extract_uris has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_uris(domain_or_domains)
            Array(domain_or_domains).map do |str|
              domain = begin
                if str.include?('@')
                  str.split('@', 2).last
      Severity: Minor
      Found in app/models/email_domain_block.rb - About 55 mins 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 body_from_webfinger has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def body_from_webfinger(url = standard_url, use_fallback = true)
          webfinger_request(url).perform do |res|
            if res.code == 200
              body = res.body_with_limit
              raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty?
      Severity: Minor
      Found in app/lib/webfinger.rb - About 55 mins 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