glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Method account_link_to has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def account_link_to(account, button = '', path: nil)
    content_tag(:div, class: 'account account--minimal') 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

    Method calculate_scores has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def calculate_scores(preview_cards, at_time)
        items = preview_cards.map do |preview_card|
          expected  = preview_card.history.get(at_time - 1.day).accounts.to_f
          expected  = 1.0 if expected.zero?
          observed  = preview_card.history.get(at_time).accounts.to_f
    Severity: Minor
    Found in app/models/trends/links.rb - About 1 hr to fix

      Method import_bookmarks! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def import_bookmarks!
          parse_import_data!(['#uri'])
          items = @data.take(ROWS_PROCESSING_LIMIT).map { |row| row['#uri'].strip }
      
          if @import.overwrite?
      Severity: Minor
      Found in app/services/import_service.rb - About 1 hr to fix

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

          def to_s
            return html if custom_emojis.empty? || html.blank?
        
            tree = Nokogiri::HTML5.fragment(html)
            tree.xpath('./text()|.//text()[not(ancestor[@class="invisible"])]').to_a.each do |node|
        Severity: Minor
        Found in app/lib/emoji_formatter.rb - About 1 hr to fix

          Method default_filter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def default_filter
                {
                  bool: {
                    should: [
                      {
          Severity: Minor
          Found in app/lib/search_query_transformer.rb - About 1 hr to fix

            Method add has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def add(*addresses)
                  fail_with_message 'No IP(s) given' if addresses.empty?
            
                  skipped   = 0
                  processed = 0
            Severity: Minor
            Found in lib/mastodon/cli/ip_blocks.rb - About 1 hr to fix

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

                def meta
                  store = default_meta_store
              
                  if object.current_account
                    store[:me]                = object.current_account.id.to_s
              Severity: Minor
              Found in app/serializers/initial_state_serializer.rb - About 1 hr to fix

                Method rewrite_follows! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def rewrite_follows!
                    num_moved = 0
                
                    # First, approve pending follow requests for the new account,
                    # this allows correctly processing list memberships with pending
                Severity: Minor
                Found in app/workers/move_worker.rb - About 1 hr to fix

                  Method refresh has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def refresh(*usernames)
                        if options[:domain] || options[:all]
                          scope  = Account.remote
                          scope  = scope.where(domain: options[:domain]) if options[:domain]
                  
                  
                  Severity: Minor
                  Found in lib/mastodon/cli/accounts.rb - About 1 hr to fix

                    Method deduplicate_local_accounts! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def deduplicate_local_accounts!(scope)
                          accounts = scope.order(id: :desc).includes(:account_stat, :user).to_a
                    
                          say "Multiple local accounts were found for username '#{accounts.first.username}'.", :yellow
                          say 'All those accounts are distinct accounts but only the most recently-created one is fully-functional.', :yellow
                    Severity: Minor
                    Found in lib/mastodon/cli/maintenance.rb - About 1 hr to fix

                      Function showAlertForError has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const showAlertForError = (error: unknown, skipNotFound = false) => {
                        if (error instanceof AxiosError && error.response) {
                          const { status, statusText, headers } = error.response;
                          const { data } = error.response as AxiosResponse<ApiErrorResponse>;
                      
                      
                      Severity: Minor
                      Found in app/javascript/flavours/glitch/actions/alerts.ts - About 1 hr to fix

                        Function showAlertForError has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const showAlertForError = (error: unknown, skipNotFound = false) => {
                          if (error instanceof AxiosError && error.response) {
                            const { status, statusText, headers } = error.response;
                            const { data } = error.response as AxiosResponse<ApiErrorResponse>;
                        
                        
                        Severity: Minor
                        Found in app/javascript/mastodon/actions/alerts.ts - About 1 hr to fix

                          Function onChangeRegistrationMode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const onChangeRegistrationMode = (target: HTMLSelectElement) => {
                            const enabled = target.value === 'approved';
                          
                            document
                              .querySelectorAll<HTMLElement>(
                          Severity: Minor
                          Found in app/javascript/flavours/glitch/entrypoints/admin.tsx - About 1 hr to fix

                            Function onChangeRegistrationMode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const onChangeRegistrationMode = (target: HTMLSelectElement) => {
                              const enabled = target.value === 'approved';
                            
                              document
                                .querySelectorAll<HTMLElement>(
                            Severity: Minor
                            Found in app/javascript/entrypoints/admin.tsx - About 1 hr to fix

                              Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                render () {
                                  const { multiColumn, intl, server, extendedDescription, domainBlocks } = this.props;
                                  const isLoading = server.get('isLoading');
                              
                                  return (
                              Severity: Minor
                              Found in app/javascript/flavours/glitch/features/about/index.jsx - 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 makeMapStateToProps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              const makeMapStateToProps = () => {
                                const getStatus = makeGetStatus();
                                const getPictureInPicture = makeGetPictureInPicture();
                              
                                const mapStateToProps = (state, props) => {
                              Severity: Minor
                              Found in app/javascript/flavours/glitch/containers/status_container.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 getNextOpen has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function getNextOpen(now) {
                                  var days = [[0, 14], [4, 18], [8, 22], [12], [2, 16], [6, 20], [10]]
                                  var nowday = now.getUTCDay();
                                  var nour = now.getUTCHours();
                              
                              
                              Severity: Minor
                              Found in public/clock.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 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                render () {
                                  const { media, lang, sensitive, letterbox, fullwidth, defaultWidth, autoplay } = this.props;
                                  const { visible } = this.state;
                                  const size     = media.size;
                                  const uncached = media.every(attachment => attachment.get('type') === 'unknown');
                              Severity: Minor
                              Found in app/javascript/flavours/glitch/components/media_gallery.jsx - 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 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                render () {
                                  const { handleChange } = this;
                                  const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props;
                                  let enabled = !disabled;
                              
                              

                              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 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                render () {
                                  const { announcement } = this.props;
                                  const { unread } = this.state;
                                  const startsAt = announcement.get('starts_at') && new Date(announcement.get('starts_at'));
                                  const endsAt = announcement.get('ends_at') && new Date(announcement.get('ends_at'));

                              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