mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

class Admin::Metrics::Measure::BaseMeasure
  CACHE_TTL = 5.minutes.freeze

  def self.with_params?
    false
Severity: Minor
Found in app/lib/admin/metrics/measure/base_measure.rb - About 2 hrs to fix

    Method open has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def open(host, *args)
            outer_e = nil
            port    = args.first
    
            addresses = []
    Severity: Major
    Found in app/lib/request.rb - About 2 hrs to fix

      Method deploy has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def deploy
            if options[:concurrency] < 1
              say('Cannot run with this concurrency setting, must be at least 1', :red)
              exit(1)
            end
      Severity: Major
      Found in lib/mastodon/search_cli.rb - About 2 hrs to fix

        File language_dropdown.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import PropTypes from 'prop-types';
        import { injectIntl, defineMessages } from 'react-intl';
        import TextIconButton from './text_icon_button';
        import Overlay from 'react-overlays/lib/Overlay';

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

            render () {
              const {
                icon,
                items,
                size,
          Severity: Major
          Found in app/javascript/mastodon/components/dropdown_menu.js - About 2 hrs to fix

            Function connectTimelineStream has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              connectStream(channelName, params, (dispatch, getState) => {
                const locale = getState().getIn(['meta', 'locale']);
            
                let pollingId;
            
            
            Severity: Major
            Found in app/javascript/mastodon/actions/streaming.js - About 2 hrs to fix

              Function getData has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getData(emoji, skin, set) {
                let emojiData = {};
              
                if (typeof emoji === 'string') {
                  let matches = emoji.match(COLONS_REGEX);
              Severity: Major
              Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 2 hrs to fix

                Function normalizeStatus has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function normalizeStatus(status, normalOldStatus) {
                  const normalStatus   = { ...status };
                  normalStatus.account = status.account.id;
                
                  if (status.reblog && status.reblog.id) {
                Severity: Major
                Found in app/javascript/mastodon/actions/importer/normalizer.js - About 2 hrs to fix

                  File action_bar.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React from 'react';
                  import PropTypes from 'prop-types';
                  import { connect } from 'react-redux';
                  import IconButton from '../../../components/icon_button';
                  import ImmutablePropTypes from 'react-immutable-proptypes';
                  Severity: Minor
                  Found in app/javascript/mastodon/features/status/components/action_bar.js - About 2 hrs to fix

                    Function StatusTranslation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function StatusTranslation ({ status })  {
                      /**
                       * @type {string}
                       * */
                      const locale = document.querySelector('html').getAttribute('lang');
                    Severity: Minor
                    Found in app/javascript/mastodon/components/status_translation.js - 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 16 (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/follower_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 calculate_scores has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def calculate_scores(preview_cards, at_time)
                        global_items = []
                        locale_items = Hash.new { |h, key| h[key] = [] }
                    
                        preview_cards.each do |preview_card|
                    Severity: Minor
                    Found in app/models/trends/links.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 preprocess_attributes! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def preprocess_attributes!
                        @sensitive    = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
                        @text         = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
                        @visibility   = @options[:visibility] || @account.user&.setting_default_privacy
                        @visibility   = :unlisted if @visibility&.to_sym == :public && @account.silenced?
                    Severity: Minor
                    Found in app/services/post_status_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 call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def call(uri, id: true, prefetched_body: nil, on_behalf_of: nil)
                        @json = begin
                          if prefetched_body.nil?
                            fetch_resource(uri, id, on_behalf_of)
                          else
                    Severity: Minor
                    Found in app/services/activitypub/fetch_remote_status_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 to has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def to(status)
                        case status.visibility
                        when 'public'
                          [COLLECTIONS[:public]]
                        when 'unlisted', 'private'
                    Severity: Minor
                    Found in app/lib/activitypub/tag_manager.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 process_items has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def process_items(items)
                        status_ids = items.filter_map do |item|
                          uri = value_or_id(item)
                          next if ActivityPub::TagManager.instance.local_uri?(uri)
                    
                    
                    Severity: Minor
                    Found in app/services/activitypub/fetch_featured_collection_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 parse_and_transform has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def parse_and_transform
                        return if @source_html.blank?
                    
                        parsed_html = Nokogiri::HTML.fragment(@source_html)
                    
                    
                    Severity: Minor
                    Found in app/lib/toc_generator.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 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def perform
                        return if under_load?
                    
                        budget = compute_budget
                        first_policy_id = last_processed_id
                    Severity: Minor
                    Found in app/workers/scheduler/accounts_statuses_cleanup_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

                    Method create has a Cognitive Complexity of 16 (exceeds 5 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 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 merge_with! has a Cognitive Complexity of 16 (exceeds 5 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 lib/mastodon/maintenance_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

                    Severity
                    Category
                    Status
                    Source
                    Language