mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Method add_to_feed has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def add_to_feed(timeline_type, account_id, status, aggregate_reblogs: true)
    timeline_key = key(timeline_type, account_id)
    reblog_key   = key(timeline_type, account_id, 'reblogs')

    if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
Severity: Minor
Found in app/lib/feed_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 import! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def import!
    # The idea is that instead of iterating over all statuses in the database
    # and calculating the searchable_by for each of them (majority of which
    # would be empty), we approach the index from the other end

Severity: Minor
Found in app/lib/importer/statuses_index_importer.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 filter_from_home? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_from_home?(status, receiver_id, crutches)
    return false if receiver_id == status.account_id
    return true  if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)

    check_for_blocks = crutches[:active_mentions][status.id] || []
Severity: Minor
Found in app/lib/feed_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

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

  render () {
    const { isLoading, results } = this.props;
    const { type } = this.state;

    let filteredResults = ImmutableList();
Severity: Minor
Found in app/javascript/mastodon/features/explore/results.js - About 1 hr to fix

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

      render () {
        const { type, src, currentTime, accountId, statusId } = this.props;
    
        if (!currentTime) {
          return null;
    Severity: Minor
    Found in app/javascript/mastodon/features/picture_in_picture/index.js - About 1 hr to fix

      Method advanced_search_for_sql_template has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def advanced_search_for_sql_template(following)
            if following
              <<-SQL.squish
                WITH first_degree AS (
                  SELECT target_account_id
      Severity: Minor
      Found in app/models/account.rb - About 1 hr to fix

        Method meta has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def meta
            store = {
              streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
              access_token: object.token,
              locale: I18n.locale,
        Severity: Minor
        Found in app/serializers/initial_state_serializer.rb - About 1 hr to fix

          Method create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create(username)
                role_id  = nil
          
                if options[:role]
                  role = UserRole.find_by(name: options[:role])
          Severity: Minor
          Found in lib/mastodon/accounts_cli.rb - About 1 hr to fix

            Function connectStream has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const connectStream = (channelName, params, callbacks) => (dispatch, getState) => {
              const streamingAPIBaseURL = getState().getIn(['meta', 'streaming_api_base_url']);
              const accessToken = getState().getIn(['meta', 'access_token']);
              const { onConnect, onReceive, onDisconnect } = callbacks(dispatch, getState);
            
            
            Severity: Minor
            Found in app/javascript/mastodon/stream.js - About 1 hr to fix

              Function announcementsReducer has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function announcementsReducer(state = initialState, action) {
                switch(action.type) {
                case ANNOUNCEMENTS_TOGGLE_SHOW:
                  return state.withMutations(map => {
                    map.set('show', !map.get('show'));
              Severity: Minor
              Found in app/javascript/mastodon/reducers/announcements.js - About 1 hr to fix

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

                  render () {
                    const { hasUnread, columnId, multiColumn, tag, intl } = this.props;
                    const { id, local } = this.props.params;
                    const pinned = !!columnId;
                
                
                Severity: Minor
                Found in app/javascript/mastodon/features/hashtag_timeline/index.js - About 1 hr to fix

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

                    render () {
                      const { draggingOver } = this.state;
                      const { children, isComposing, location, dropdownMenuIsOpen, layout } = this.props;
                  
                      const handlers = {
                  Severity: Minor
                  Found in app/javascript/mastodon/features/ui/index.js - About 1 hr to fix

                    Method merge_with! has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def merge_with!(other_account)
                        # Since it's the same remote resource, the remote resource likely
                        # already believes we are following/blocking, so it's safe to
                        # re-attribute the relationships too. However, during the presence
                        # of the index bug users could have *also* followed the reference
                    Severity: Minor
                    Found in app/models/concerns/account_merging.rb - About 1 hr to fix

                      Method set_descendants has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def set_descendants
                          @max_descendant_thread_id   = params[:max_descendant_thread_id]&.to_i
                          @since_descendant_thread_id = params[:since_descendant_thread_id]&.to_i
                      
                          descendants = cache_collection(
                      Severity: Minor
                      Found in app/controllers/concerns/status_controller_concern.rb - About 1 hr to fix

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

                          render () {
                            const { intl, multiColumn, isSearching, layout } = this.props;
                        
                            return (
                              <Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
                        Severity: Minor
                        Found in app/javascript/mastodon/features/explore/index.js - About 1 hr to fix

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

                            render () {
                              const { isLoading, accountIds, intl, columnId, multiColumn, domain } = this.props;
                              const { order, local }  = this.getParams(this.props, this.state);
                              const pinned = !!columnId;
                          
                          
                          Severity: Minor
                          Found in app/javascript/mastodon/features/directory/index.js - About 1 hr to fix

                            Method parallelize_with_progress has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def parallelize_with_progress(scope)
                                  if options[:concurrency] < 1
                                    say('Cannot run with this concurrency setting, must be at least 1', :red)
                                    exit(1)
                                  end
                            Severity: Minor
                            Found in lib/mastodon/cli_helper.rb - About 1 hr to fix

                              Function handlePush has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const handlePush = (event) => {
                                const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();
                              
                                // Placeholder until more information can be loaded
                                event.waitUntil(
                              Severity: Minor
                              Found in app/javascript/mastodon/service_worker/web_push_notifications.js - About 1 hr to fix

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

                                  render () {
                                    const { intl, accountIds, hasMore, multiColumn, locked, domain, isLoading } = this.props;
                                
                                    if (!accountIds) {
                                      return (
                                Severity: Minor
                                Found in app/javascript/mastodon/features/follow_requests/index.js - About 1 hr to fix

                                  Method to_s has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def to_s
                                      return html if custom_emojis.empty? || html.blank?
                                  
                                      i                     = -1
                                      tag_open_index        = nil
                                  Severity: Minor
                                  Found in app/lib/emoji_formatter.rb - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language