glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Method set_fetchable_attributes! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def set_fetchable_attributes!
    begin
      @account.avatar_remote_url = image_url('icon') || '' unless skip_download?
      @account.avatar = nil if @account.avatar_remote_url.blank?
    rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
Severity: Minor
Found in app/services/activitypub/process_account_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 populate_direct_feed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def populate_direct_feed(account)
    added  = 0
    limit  = FeedManager::MAX_ITEMS / 2
    max_id = nil

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

    def reset_relationships(username)
      fail_with_message 'Please specify either --follows or --followers, or both' unless options[:follows] || options[:followers]

      account = Account.find_local(username)

Severity: Minor
Found in lib/mastodon/cli/accounts.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 merge_statuses! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def merge_statuses!(main_status, duplicate_status)
      owned_classes = [Favourite, Mention, Poll]
      owned_classes << Bookmark if db_table_exists?(:bookmarks)
      owned_classes.each do |klass|
        klass.where(status_id: duplicate_status.id).find_each do |record|
Severity: Minor
Found in lib/mastodon/cli/maintenance.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 post_process_style has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def post_process_style(name, style) # :nodoc:
      raise "Style #{name} has no processors defined." if style.processors.blank?

      intermediate_files = []
      original = @queued_for_write[:original]
Severity: Minor
Found in lib/paperclip/attachment_extensions.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 lookup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def lookup(url)
      path = Addressable::URI.parse(url).path

      path_segments = path.split('/')[2..]
      path_segments.delete('cache')
Severity: Minor
Found in lib/mastodon/cli/media.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 InlineFollowSuggestions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ hidden }) => {
  const intl = useIntl();
  const dispatch = useAppDispatch();
  const suggestions = useAppSelector((state) => state.suggestions.items);
  const isLoading = useAppSelector((state) => state.suggestions.isLoading);

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

}> = ({ hidden }) => {
  const intl = useIntl();
  const dispatch = useAppDispatch();
  const suggestions = useAppSelector((state) => state.suggestions.items);
  const isLoading = useAppSelector((state) => state.suggestions.isLoading);

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 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { Message } = this;
    const { type, children } = this.props;

    let iconId, iconComponent;
Severity: Minor
Found in app/javascript/flavours/glitch/components/status_prepend.jsx - About 1 hr to fix

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

      render () {
        const { intl, resetFileKey, disabled, acceptContentTypes } = this.props;
    
        const message = intl.formatMessage(messages.upload);
    
    

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

        render () {
          const { accountId, statusIds, featuredStatusIds, isLoading, hasMore, suspended, isAccount, hidden, multiColumn, remote, remoteUrl } = this.props;
      
          if (isLoading && statusIds.isEmpty()) {
            return (
      Severity: Minor
      Found in app/javascript/flavours/glitch/features/account_timeline/index.jsx - About 1 hr to fix

        Function updateNotifications has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function updateNotifications(notification, intlMessages, intlLocale) {
          return (dispatch, getState) => {
            const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
            const showInColumn = activeFilter === 'all' ? getState().getIn(['settings', 'notifications', 'shows', notification.type], true) : activeFilter === notification.type;
            const showAlert    = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
        Severity: Minor
        Found in app/javascript/flavours/glitch/actions/notifications.js - About 1 hr to fix

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

            render () {
              const { notification } = this.props;
              const account          = notification.get('account');
              const displayNameHtml  = { __html: account.get('display_name_html') };
              const link             = (

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

              render () {
                const { multiColumn, intl } = this.props;
            
                if (multiColumn) {
                  const { columns } = this.props;
            Severity: Minor
            Found in app/javascript/mastodon/features/compose/index.jsx - About 1 hr to fix

              Function expandNormalizedNotifications has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const expandNormalizedNotifications = (state, notifications, next, isLoadingMore, isLoadingRecent, usePendingItems) => {
                // This method is pretty tricky because:
                // - existing notifications might be out of order
                // - the existing notifications may have gaps, most often explicitly noted with a `null` item
                // - ideally, we don't want it to reorder existing items
              Severity: Minor
              Found in app/javascript/flavours/glitch/reducers/notifications.js - About 1 hr to fix

                Function updateNotifications has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function updateNotifications(notification, intlMessages, intlLocale) {
                  return (dispatch, getState) => {
                    const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
                    const showInColumn = activeFilter === 'all' ? getState().getIn(['settings', 'notifications', 'shows', notification.type], true) : activeFilter === notification.type;
                    const showAlert    = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
                Severity: Minor
                Found in app/javascript/mastodon/actions/notifications.js - About 1 hr to fix

                  Method make has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def make
                        background_palette, foreground_palette = Rails.configuration.x.use_vips ? palettes_from_libvips : palettes_from_imagemagick
                  
                        background_color   = background_palette.first || foreground_palette.first
                        foreground_colors  = []
                  Severity: Minor
                  Found in lib/paperclip/color_extractor.rb - About 1 hr to fix

                    Method storage_schema has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def storage_schema
                          progress = create_progress_bar(nil)
                          records  = 0
                    
                          klasses = [
                    Severity: Minor
                    Found in lib/mastodon/cli/upgrade.rb - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (multiColumn) {
                            const { columns } = this.props;
                      
                            return (
                              <div className='drawer' role='region' aria-label={intl.formatMessage(messages.compose)}>
                      Severity: Critical
                      Found in app/javascript/flavours/glitch/features/compose/index.jsx - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                          else if (
                            followAccountSuccess.match(action) ||
                            unfollowAccountSuccess.match(action) ||
                            blockAccountSuccess.match(action) ||
                            unblockAccountSuccess.match(action) ||
                        Severity: Critical
                        Found in app/javascript/flavours/glitch/reducers/relationships.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language