mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Consider simplifying this complex logical expression.
Open

    } else if (attachment.get('type') === 'image') {
      const previewUrl   = attachment.get('preview_url');
      const previewWidth = attachment.getIn(['meta', 'small', 'width']);

      const originalUrl   = attachment.get('url');
Severity: Major
Found in app/javascript/mastodon/components/media_gallery.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        } else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
          statuses = (
            <div className='search-results__section'>
              <h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
    
    
    Severity: Major
    Found in app/javascript/mastodon/features/compose/components/search_results.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

        if (typeof hasBoundingRectBug !== 'boolean') {
          const boundingRect = entry.target.getBoundingClientRect();
          const observerRect = entry.boundingClientRect;
          hasBoundingRectBug = boundingRect.height !== observerRect.height ||
            boundingRect.top !== observerRect.top ||
      Severity: Major
      Found in app/javascript/mastodon/features/ui/util/get_rect_from_entry.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            } else if (!statuses.isEmpty()) {
              usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('pendingItems').isEmpty());
        
              mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => {
                const newIds = statuses.map(status => status.get('id'));
        Severity: Major
        Found in app/javascript/mastodon/reducers/timelines.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (!items.isEmpty()) {
                usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('pendingItems').isEmpty());
          
                mutable.update(usePendingItems ? 'pendingItems' : 'items', list => {
                  const lastIndex = 1 + list.findLastIndex(
          Severity: Major
          Found in app/javascript/mastodon/reducers/notifications.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                } else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
                  statuses = (
                    <div className='search-results__section'>
                      <h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
            
            
            Severity: Major
            Found in app/javascript/mastodon/features/compose/components/search_results.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  if (filter[3] || filter[4]) {
                    warning = (
                      <span className='language-dropdown__dropdown__results__item__common-name'>
                        (
                        {filter[3] && <FormattedMessage id='filter_modal.select_filter.expired' defaultMessage='expired' />}
              Severity: Major
              Found in app/javascript/mastodon/features/filters/select_filter.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                    if preloaded.nil?
                      ids += mentions.where(account: Account.local, silent: false).pluck(:account_id)
                      ids += favourites.where(account: Account.local).pluck(:account_id)
                      ids += reblogs.where(account: Account.local).pluck(:account_id)
                      ids += bookmarks.where(account: Account.local).pluck(:account_id)
                Severity: Major
                Found in app/models/status.rb - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      return unless (original_status.public_visibility? && status.public_visibility?) &&
                                    !(original_status.account.silenced? || status.account.silenced?) &&
                                    !(original_status.spoiler_text? || original_status.sensitive?)
                  Severity: Major
                  Found in app/models/trends/links.rb - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                      if (process.env.SOCKET || process.env.PORT && isNaN(+process.env.PORT)) {
                        server.listen(process.env.SOCKET || process.env.PORT, () => {
                          if (onSuccess) {
                            fs.chmodSync(server.address(), 0o666);
                            onSuccess(server.address());
                    Severity: Major
                    Found in streaming/index.js - About 40 mins to fix

                      Function expandNotificationsSuccess has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export function expandNotificationsSuccess(notifications, next, isLoadingMore, isLoadingRecent, usePendingItems) {
                      Severity: Minor
                      Found in app/javascript/mastodon/actions/notifications.js - About 35 mins to fix

                        Function setComposeToStatus has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        export function setComposeToStatus(status, text, spoiler_text, content_type, local_only) {
                        Severity: Minor
                        Found in app/javascript/mastodon/actions/compose.js - About 35 mins to fix

                          Method descendants has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def descendants(limit, account = nil, max_child_id = nil, since_child_id = nil, depth = nil)
                          Severity: Minor
                          Found in app/models/concerns/status_threading_concern.rb - About 35 mins to fix

                            Method retrieve has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              def self.retrieve(dimension_keys, start_at, end_at, limit, params)
                            Severity: Minor
                            Found in app/lib/admin/metrics/dimension.rb - About 35 mins to fix

                              Method import_relationships! has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                def import_relationships!(action, undo_action, overwrite_scope, limit, extra_fields = {})
                              Severity: Minor
                              Found in app/services/import_service.rb - About 35 mins to fix

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

                                  render () {
                                    const { label, href, target } = this.props;
                                    const { loading, data } = this.state;
                                
                                    let content;
                                Severity: Minor
                                Found in app/javascript/mastodon/components/admin/Counter.js - About 35 mins 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 timeRemainingString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const timeRemainingString = (intl, date, now, timeGiven = true) => {
                                  const delta = date.getTime() - now;
                                
                                  let relativeTime;
                                
                                
                                Severity: Minor
                                Found in app/javascript/mastodon/components/relative_timestamp.js - About 35 mins 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 childNodeHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const childNodeHandler = (node, stack, outerOptions = undefined) => {
                                  if (node.nodeName === TEXT_NODE_NAME) {
                                    if (node.textContent.trim()) {
                                      stack.push({ node, options: outerOptions });
                                    }
                                Severity: Minor
                                Found in translation/index.js - About 35 mins 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 percIncrease has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const percIncrease = (a, b) => {
                                  let percent;
                                
                                  if (b !== 0) {
                                    if (a !== 0) {
                                Severity: Minor
                                Found in app/javascript/mastodon/components/admin/Counter.js - About 35 mins 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 dropOrientationIfNeeded has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const dropOrientationIfNeeded = (orientation) => new Promise(resolve => {
                                  switch (_browser_quirks['image-orientation-automatic']) {
                                  case true:
                                    resolve(1);
                                    break;
                                Severity: Minor
                                Found in app/javascript/mastodon/utils/resize_image.js - About 35 mins 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

                                Severity
                                Category
                                Status
                                Source
                                Language