glitch-soc/mastodon

View on GitHub

Showing 1,291 of 4,907 total issues

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

  render () {
    const { intl, onOpenSettings } = this.props;
    const { signedIn, disabledAccountId, permissions } = this.props.identity;

    let banner = undefined;

    Function makeMapStateToProps has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const makeMapStateToProps = () => {
      const getStatus = makeGetStatus();
      const getPictureInPicture = makeGetPictureInPicture();
    
      const getAncestorsIds = createSelector([
    Severity: Major
    Found in app/javascript/mastodon/features/status/index.jsx - About 2 hrs to fix

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

        render() {
          const style = {
            ...this.props.style,
            ...(this.props.active ? this.props.activeStyle : {}),
          };
      Severity: Major
      Found in app/javascript/mastodon/components/icon_button.tsx - About 2 hrs to fix

        Function _updateStatusLinks has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _updateStatusLinks () {
            const node = this.node;
            const { tagLinks, rewriteMentions } = this.props;
        
            if (!node) {
        Severity: Major
        Found in app/javascript/flavours/glitch/components/status_content.jsx - About 2 hrs to fix

          Function statuses has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function statuses(state = initialState, action) {
            switch(action.type) {
            case STATUS_FETCH_REQUEST:
              return state.setIn([action.id, 'isLoading'], true);
            case STATUS_FETCH_FAIL:
          Severity: Major
          Found in app/javascript/flavours/glitch/reducers/statuses.js - About 2 hrs to fix

            Function statuses has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function statuses(state = initialState, action) {
              switch(action.type) {
              case STATUS_FETCH_REQUEST:
                return state.setIn([action.id, 'isLoading'], true);
              case STATUS_FETCH_FAIL:
            Severity: Major
            Found in app/javascript/mastodon/reducers/statuses.js - About 2 hrs to fix

              Function mapDispatchToProps has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              const mapDispatchToProps = (dispatch) => ({
              
                onFollow (account) {
                  if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
                    dispatch(openModal({ modalType: 'CONFIRM_UNFOLLOW', modalProps: { account } }));

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

                render () {
                  const { attachment, lang, index, size, standalone, displayWidth, visible } = this.props;
              
                  let badges = [], thumbnail;
              
              
              Severity: Minor
              Found in app/javascript/mastodon/components/media_gallery.jsx - 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

              Function mapDispatchToProps has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              const mapDispatchToProps = (dispatch) => ({
              
                onFollow (account) {
                  if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
                    dispatch(openModal({ modalType: 'CONFIRM_UNFOLLOW', modalProps: { account } }));

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

                def validate_data
                  return if data.nil?
                  return errors.add(:data, I18n.t('imports.errors.too_large')) if data.size > FILE_SIZE_LIMIT
                  return errors.add(:data, I18n.t('imports.errors.incompatible_type')) unless default_csv_headers.all? { |header| csv_data.headers.include?(header) }
              
              
              Severity: Minor
              Found in app/models/form/import.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 scan_text! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def scan_text!
                  @status.text = @status.text.gsub(Account::MENTION_RE) do |match|
                    username, domain = Regexp.last_match(1).split('@')
              
                    domain = if TagManager.instance.local_domain?(domain)
              Severity: Minor
              Found in app/services/process_mentions_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 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def call(uri, prefetched_body: nil, on_behalf_of: nil, expected_actor_uri: nil, request_id: nil)
                  return if domain_not_allowed?(uri)
              
                  @request_id = request_id || "#{Time.now.utc.to_i}-status-#{uri}"
                  @json = if prefetched_body.nil?
              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 cull has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def cull(*domains)
                    skip_threshold = 7.days.ago
                    skip_domains   = Concurrent::Set.new
              
                    query = Account.remote.activitypub
              Severity: Minor
              Found in lib/mastodon/cli/accounts.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 migrate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def migrate(username)
                    fail_with_message 'Use --replay or --target, not both' if options[:replay].present? && options[:target].present?
              
                    fail_with_message 'Use either --replay or --target' if options[:replay].blank? && options[:target].blank?
              
              
              Severity: Minor
              Found in lib/mastodon/cli/accounts.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 remove_files has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def remove_files
                  keys = []
              
                  logger.debug { "Preparing to delete attachments for #{records.size} records" }
              
              
              Severity: Major
              Found in app/lib/attachment_batch.rb - About 2 hrs to fix

                Function renderOption has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  renderOption (option, optionIndex, showResults) {
                    const { poll, lang, disabled, intl } = this.props;
                    const pollVotesCount  = poll.get('voters_count') || poll.get('votes_count');
                    const percent         = pollVotesCount === 0 ? 0 : (option.get('votes_count') / pollVotesCount) * 100;
                    const leading         = poll.get('options').filterNot(other => other.get('title') === option.get('title')).every(other => option.get('votes_count') >= other.get('votes_count'));
                Severity: Major
                Found in app/javascript/flavours/glitch/components/poll.jsx - About 2 hrs to fix

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

                    render () {
                      const { filter, contextType } = this.props;
                  
                      let expiredMessage = null;
                      if (filter.get('expires_at') && filter.get('expires_at') < new Date()) {
                  Severity: Major
                  Found in app/javascript/flavours/glitch/features/filters/added_to_filter.jsx - About 2 hrs to fix

                    Function renderOption has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      renderOption (option, optionIndex, showResults) {
                        const { poll, lang, disabled, intl } = this.props;
                        const pollVotesCount  = poll.get('voters_count') || poll.get('votes_count');
                        const percent         = pollVotesCount === 0 ? 0 : (option.get('votes_count') / pollVotesCount) * 100;
                        const leading         = poll.get('options').filterNot(other => other.get('title') === option.get('title')).every(other => option.get('votes_count') >= other.get('votes_count'));
                    Severity: Major
                    Found in app/javascript/mastodon/components/poll.jsx - About 2 hrs to fix

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

                        render () {
                          const { filter, contextType } = this.props;
                      
                          let expiredMessage = null;
                          if (filter.get('expires_at') && filter.get('expires_at') < new Date()) {
                      Severity: Major
                      Found in app/javascript/mastodon/features/filters/added_to_filter.jsx - About 2 hrs to fix

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

                          render() {
                            const { others, localDomain } = this.props;
                        
                            let displayName: React.ReactNode,
                              suffix: React.ReactNode,
                        Severity: Major
                        Found in app/javascript/flavours/glitch/components/display_name.tsx - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language