mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

    def fix_duplicates
      @prompt = TTY::Prompt.new

      if ActiveRecord::Migrator.current_version < MIN_SUPPORTED_VERSION
        @prompt.error 'Your version of the database schema is too old and is not supported by this script.'
Severity: Minor
Found in lib/mastodon/maintenance_cli.rb - About 1 hr to fix

    Function connectTimelineStream has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export const connectTimelineStream = (timelineId, channelName, params = {}, options = {}) =>
      connectStream(channelName, params, (dispatch, getState) => {
        const locale = getState().getIn(['meta', 'locale']);
    
        let pollingId;
    Severity: Minor
    Found in app/javascript/mastodon/actions/streaming.js - 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 unicodeToFilename has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.unicodeToFilename = (str) => {
      let result = '';
      let charCode = 0;
      let p = 0;
      let i = 0;
    Severity: Minor
    Found in app/javascript/mastodon/features/emoji/unicode_to_filename.js - 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { statusIds, featuredStatusIds, onLoadMore, timelineId, ...other }  = this.props;
        const { isLoading, isPartial } = other;
    
        if (isPartial) {
    Severity: Minor
    Found in app/javascript/mastodon/components/status_list.js - 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 mapDispatchToProps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    const mapDispatchToProps = (dispatch, { intl }) => ({
      onFollow(account) {
        if (
          account.getIn(['relationship', 'following']) ||
          account.getIn(['relationship', 'requested'])

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

    export default function notifications(state = initialState, action) {
      switch(action.type) {
      case MARKERS_FETCH_SUCCESS:
        return action.markers.notifications ? recountUnread(state, action.markers.notifications.last_read_id) : state;
      case NOTIFICATIONS_MOUNT:
    Severity: Minor
    Found in app/javascript/mastodon/reducers/notifications.js - 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { intl, results, suggestions, dismissSuggestion, searchTerm } = this.props;
    
        if (searchTerm === '' && !suggestions.isEmpty()) {
          return (

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

      def matches_time_window?
        created_time = nil
        expires_time = nil
    
        begin
    Severity: Minor
    Found in app/controllers/concerns/signature_verification.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 account_link_to has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def account_link_to(account, button = '', path: nil)
        content_tag(:div, class: 'account') do
          content_tag(:div, class: 'account__wrapper') do
            section = if account.nil?
                        content_tag(:div, class: 'account__display-name') do
    Severity: Minor
    Found in app/helpers/home_helper.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 account_action_button has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def account_action_button(account)
        if user_signed_in?
          if account.id == current_user.account_id
            link_to settings_profile_url, class: 'button logo-button' do
              safe_join([logo_as_symbol, t('settings.edit_profile')])
    Severity: Minor
    Found in app/helpers/accounts_helper.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 update_count! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_count!(key, value)
        raise ArgumentError, "Invalid key #{key}" unless ALLOWED_COUNTER_KEYS.include?(key)
        raise ArgumentError, 'Do not call update_count! on dirty objects' if association(:account_stat).loaded? && account_stat&.changed? && account_stat.changed_attribute_names_to_save == %w(id)
    
        value = value.to_i
    Severity: Minor
    Found in app/models/concerns/account_counters.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 invalidate_last_inspected has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def invalidate_last_inspected(status, action)
        last_value = last_inspected
        return if last_value.nil? || status.id > last_value || status.account_id != account_id
    
        case action
    Severity: Minor
    Found in app/models/account_statuses_cleanup_policy.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 create_for_oauth has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_for_oauth(auth)
          Rails.logger.info "Creating user for #{auth.provider} identity"
          Rails.logger.info "  auth.info: #{auth.info.to_json}"
          Rails.logger.info "  auth.uid: #{auth.uid}"
          # Check if the user exists with provided email. If no email was provided,
    Severity: Minor
    Found in app/models/concerns/omniauthable.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 set_descendants has a Cognitive Complexity of 12 (exceeds 5 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

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

      def accounts_scope
        Account.discoverable.tap do |scope|
          scope.merge!(Account.local)                                          if truthy_param?(:local)
          scope.merge!(Account.by_recent_status)                               if params[:order].blank? || params[:order] == 'active'
          scope.merge!(Account.order(id: :desc))                               if params[:order] == 'new'
    Severity: Minor
    Found in app/controllers/api/v1/directories_controller.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 extract_mentions_or_lists_with_indices has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def extract_mentions_or_lists_with_indices(text)
        return [] unless text && Twitter::TwitterText::Regex[:at_signs].match?(text)
    
        possible_entries = []
    
    
    Severity: Minor
    Found in app/lib/extractor.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 update_mentions! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_mentions!
        previous_mentions = @status.active_mentions.includes(:account).to_a
        current_mentions  = []
    
        @raw_mentions.each do |href|
    Severity: Minor
    Found in app/services/activitypub/process_status_update_service.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 perform_statuses_search! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform_statuses_search!
        definition = parsed_query.apply(StatusesIndex.filter(term: { searchable_by: @account.id }))
    
        if @options[:account_id].present?
          definition = definition.filter(term: { account_id: @options[:account_id] })
    Severity: Minor
    Found in app/services/search_service.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 assign_mentions! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def assign_mentions!
        @current_mentions.each do |mention|
          mentioned_account = mention.account
    
          if mentioned_account.local?
    Severity: Minor
    Found in app/services/process_mentions_service.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 delete_note has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def delete_note
        return if object_uri.nil?
    
        with_lock("delete_status_in_progress:#{object_uri}", raise_on_failure: false) do
          unless invalid_origin?(object_uri)
    Severity: Minor
    Found in app/lib/activitypub/activity/delete.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

    Severity
    Category
    Status
    Source
    Language