mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Method self_destruct has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def self_destruct
      require 'tty-prompt'

      prompt = TTY::Prompt.new

Severity: Minor
Found in lib/cli.rb - About 3 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

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

  render () {
    const { card, maxDescription, compact, quote } = this.props;
    const { width, embedded, revealed } = this.state;

    if (card === null) {
Severity: Major
Found in app/javascript/mastodon/features/status/components/card.js - About 3 hrs to fix

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

      render () {
        const { src, intl, alt, editable, autoPlay, sensitive, blurhash } = this.props;
        const { paused, muted, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
        const progress = Math.min((currentTime / duration) * 100, 100);
    
    
    Severity: Major
    Found in app/javascript/mastodon/features/audio/index.js - About 3 hrs to fix

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

        render () {
          const { loading, data } = this.state;
          const { frequency } = this.props;
      
          let content;
      Severity: Major
      Found in app/javascript/mastodon/components/admin/Retention.js - About 3 hrs to fix

        Function timeAgoString has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        export const timeAgoString = (intl, date, now, year, timeGiven, short) => {
          const delta = now - date.getTime();
        
          let relativeTime;
        
        
        Severity: Minor
        Found in app/javascript/mastodon/components/relative_timestamp.js - About 3 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

        Function normalizeStatus has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        export function normalizeStatus(status, normalOldStatus) {
          const normalStatus   = { ...status };
          normalStatus.account = status.account.id;
        
          if (status.reblog && status.reblog.id) {
        Severity: Minor
        Found in app/javascript/mastodon/actions/importer/normalizer.js - About 3 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

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

          render () {
            const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
            const { collapsed, animating } = this.state;
        
            const wrapperClassName = classNames('column-header__wrapper', {
        Severity: Minor
        Found in app/javascript/mastodon/components/column_header.js - About 3 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

        Function renderItem has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          renderItem (account, size, index) {
            const { animate } = this.props;
        
            let width  = 50;
            let height = 100;
        Severity: Minor
        Found in app/javascript/mastodon/components/avatar_composite.js - About 3 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_s has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def to_s
            return html if custom_emojis.empty? || html.blank?
        
            i                     = -1
            tag_open_index        = nil
        Severity: Minor
        Found in app/lib/emoji_formatter.rb - About 3 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

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

          render () {
            let ancestors, descendants;
            const { status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
            const { fullscreen } = this.state;
        
        
        Severity: Major
        Found in app/javascript/mastodon/features/status/index.js - About 3 hrs to fix

          Function channelNameToIds has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const channelNameToIds = (req, name, params) => new Promise((resolve, reject) => {
              switch (name) {
              case 'user':
                resolve({
                  channelIds: channelsForUserStream(req),
          Severity: Major
          Found in streaming/index.js - About 3 hrs to fix

            Class LinkDetailsExtractor has 29 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class LinkDetailsExtractor
              include ActionView::Helpers::TagHelper
              include LanguagesHelper
            
              # Some publications wrap their JSON-LD data in their <script> tags
            Severity: Minor
            Found in app/lib/link_details_extractor.rb - About 3 hrs to fix

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

                render () {
                  const { status, quote } = this.props;
              
                  const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden;
                  const renderReadMore = this.props.onClick && status.get('collapsed');
              Severity: Major
              Found in app/javascript/mastodon/components/status_content.js - About 3 hrs to fix

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

                  render () {
                    const {
                      accountId,
                      account,
                      intl,
                Severity: Major
                Found in app/javascript/mastodon/features/ui/components/report_modal.js - About 3 hrs to fix

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

                    def discover_endpoint!
                      return if html.nil?
                  
                      @format = @options[:format]
                      page    = Nokogiri::HTML(html)
                  Severity: Minor
                  Found in app/services/fetch_oembed_service.rb - About 3 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 patch_for_forwarding! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def patch_for_forwarding!(original, compacted)
                      original.without('@context', 'signature').each do |key, value|
                        next if value.nil? || !compacted.key?(key)
                  
                        compacted_value = compacted[key]
                  Severity: Minor
                  Found in app/helpers/jsonld_helper.rb - About 3 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 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def call(query, account, limit, options = {})
                      @query   = query&.strip
                      @account = account
                      @options = options
                      @limit   = limit.to_i
                  Severity: Minor
                  Found in app/services/search_service.rb - About 3 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

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

                    render () {
                      const { status, relationship, intl } = this.props;
                  
                      const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
                      const pinnableStatus     = ['public', 'unlisted', 'private'].includes(status.get('visibility'));
                  Severity: Major
                  Found in app/javascript/mastodon/features/status/components/action_bar.js - About 3 hrs to fix

                    File header.js has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React from 'react';
                    import ImmutablePropTypes from 'react-immutable-proptypes';
                    import PropTypes from 'prop-types';
                    import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
                    import Button from 'mastodon/components/button';
                    Severity: Minor
                    Found in app/javascript/mastodon/features/account/components/header.js - About 3 hrs to fix

                      Class DeleteAccountService has 28 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class DeleteAccountService < BaseService
                        include Payloadable
                      
                        ASSOCIATIONS_ON_SUSPEND = %w(
                          account_notes
                      Severity: Minor
                      Found in app/services/delete_account_service.rb - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language