glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Method uri_to_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def uri_to_resource(uri, klass)
    return if uri.nil?

    if local_uri?(uri)
      case klass.name
Severity: Minor
Found in app/lib/activitypub/tag_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 perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(id)
    account = Account.find(id)

    return if account.suspended? || DomainBlock.rule_for(account.domain)&.reject_media?
    return if account.avatar_remote_url.blank? || account.avatar_file_name.present?
Severity: Minor
Found in app/workers/redownload_avatar_worker.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 url_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def url_for(target)
    return target.url if target.respond_to?(:local?) && !target.local?

    return unless target.respond_to?(:object_type)

Severity: Minor
Found in app/lib/activitypub/tag_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 perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(id)
    account = Account.find(id)

    return if account.suspended? || DomainBlock.rule_for(account.domain)&.reject_media?
    return if account.header_remote_url.blank? || account.header_file_name.present?
Severity: Minor
Found in app/workers/redownload_header_worker.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 stats_to_summary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def stats_to_summary(stats, processed, failed, start_at)
      stats.compact!

      total_domains = stats.size
      total_users   = stats.reduce(0) { |sum, (_key, val)| val.is_a?(Hash) && val['stats'].is_a?(Hash) ? sum + val['stats']['user_count'].to_i : sum }
Severity: Minor
Found in lib/mastodon/cli/domains.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 processNewNotification has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function processNewNotification(
  groups: NotificationGroupsState['groups'],
  notification: ApiNotificationJSON,
  groupedTypes: NotificationType[],
) {
Severity: Minor
Found in app/javascript/flavours/glitch/reducers/notification_groups.ts - 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 ListMembers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ multiColumn }) => {
  const dispatch = useAppDispatch();
  const { id } = useParams<{ id: string }>();
  const intl = useIntl();

Severity: Minor
Found in app/javascript/flavours/glitch/features/lists/members.tsx - 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 computeHashtagBarForStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function computeHashtagBarForStatus(status: StatusLike): {
  statusContentProps: { statusContent: string };
  hashtagsInBar: string[];
} {
  let statusContent = getStatusContent(status);
Severity: Minor
Found in app/javascript/mastodon/components/hashtag_bar.tsx - 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 computeHashtagBarForStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function computeHashtagBarForStatus(status: StatusLike): {
  statusContentProps: { statusContent: string };
  hashtagsInBar: string[];
} {
  let statusContent = getStatusContent(status);
Severity: Minor
Found in app/javascript/flavours/glitch/components/hashtag_bar.tsx - 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 ListMembers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ multiColumn }) => {
  const dispatch = useAppDispatch();
  const { id } = useParams<{ id: string }>();
  const intl = useIntl();

Severity: Minor
Found in app/javascript/mastodon/features/lists/members.tsx - 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 processNewNotification has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function processNewNotification(
  groups: NotificationGroupsState['groups'],
  notification: ApiNotificationJSON,
  groupedTypes: NotificationType[],
) {
Severity: Minor
Found in app/javascript/mastodon/reducers/notification_groups.ts - 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 importFetchedStatuses has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function importFetchedStatuses(statuses) {
  return (dispatch, getState) => {
    const accounts = [];
    const normalStatuses = [];
    const polls = [];
Severity: Minor
Found in app/javascript/flavours/glitch/actions/importer/index.js - About 1 hr to fix

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

      render () {
        const { reactions } = this.props;
        const visibleReactions = reactions.filter(x => x.get('count') > 0);
    
        const styles = visibleReactions.map(reaction => ({

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

        render () {
          const { intl, domains, hasMore, multiColumn } = this.props;
      
          if (!domains) {
            return (
      Severity: Minor
      Found in app/javascript/flavours/glitch/features/domain_blocks/index.jsx - About 1 hr to fix

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

          render () {
            const { media, status, onClose } = this.props;
            const options = this.props.options || {};
            const language = status.getIn(['translation', 'language']) || status.get('language');
            const description = media.getIn(['translation', 'description']) || media.get('description');

          Function expandNormalizedTimeline has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Function expandNormalizedConversations has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const expandNormalizedConversations = (state, conversations, next, isLoadingRecent) => {
              let items = ImmutableList(conversations.map(conversationToMap));
            
              return state.withMutations(mutable => {
                if (!items.isEmpty()) {
            Severity: Minor
            Found in app/javascript/flavours/glitch/reducers/conversations.js - About 1 hr to fix

              Function importFetchedStatuses has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function importFetchedStatuses(statuses) {
                return (dispatch, getState) => {
                  const accounts = [];
                  const normalStatuses = [];
                  const polls = [];
              Severity: Minor
              Found in app/javascript/mastodon/actions/importer/index.js - About 1 hr to fix

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

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

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

                    render () {
                      const { reactions } = this.props;
                      const visibleReactions = reactions.filter(x => x.get('count') > 0);
                  
                      const styles = visibleReactions.map(reaction => ({
                    Severity
                    Category
                    Status
                    Source
                    Language