glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

File index.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { useCallback, useEffect, useRef } from 'react';

import { useIntl, defineMessages, FormattedMessage } from 'react-intl';

import { Helmet } from 'react-helmet';
Severity: Minor
Found in app/javascript/flavours/glitch/features/search/index.tsx - About 2 hrs to fix

    File index.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { useCallback, useEffect, useRef } from 'react';
    
    import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
    
    import { Helmet } from 'react-helmet';
    Severity: Minor
    Found in app/javascript/mastodon/features/search/index.tsx - About 2 hrs to fix

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

        render () {
          const {
            icon,
            iconComponent,
            items,
      Severity: Major
      Found in app/javascript/flavours/glitch/components/dropdown_menu.jsx - About 2 hrs to fix

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

          render () {
            const {
              icon,
              iconComponent,
              items,
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.jsx - About 2 hrs to fix

          Method merge_with! has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def merge_with!(other_account)
                  # Since it's the same remote resource, the remote resource likely
                  # already believes we are following/blocking, so it's safe to
                  # re-attribute the relationships too. However, during the presence
                  # of the index bug users could have *also* followed the reference
          Severity: Major
          Found in lib/mastodon/cli/maintenance.rb - About 2 hrs to fix

            Function PictureInPicture has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const PictureInPicture: React.FC = () => {
              const dispatch = useAppDispatch();
            
              const handleClose = useCallback(() => {
                dispatch(removePictureInPicture());
            Severity: Major
            Found in app/javascript/flavours/glitch/features/picture_in_picture/index.tsx - About 2 hrs to fix

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

                render () {
                  const { src, intl, alt, lang, editable, autoPlay, sensitive, blurhash } = this.props;
                  const { paused, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
                  const progress = Math.min((currentTime / duration) * 100, 100);
                  const muted = this.state.muted || volume === 0;
              Severity: Minor
              Found in app/javascript/flavours/glitch/features/audio/index.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 render has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                render () {
                  const { src, intl, alt, lang, editable, autoPlay, sensitive, blurhash } = this.props;
                  const { paused, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
                  const progress = Math.min((currentTime / duration) * 100, 100);
                  const muted = this.state.muted || volume === 0;
              Severity: Minor
              Found in app/javascript/mastodon/features/audio/index.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 notifications has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function notifications(state = initialState, action) {
                let st;
              
                switch(action.type) {
                case fetchMarkers.fulfilled.type:
              Severity: Minor
              Found in app/javascript/flavours/glitch/reducers/notifications.js - 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 merge_with! has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def merge_with!(other_account)
                  # Since it's the same remote resource, the remote resource likely
                  # already believes we are following/blocking, so it's safe to
                  # re-attribute the relationships too. However, during the presence
                  # of the index bug users could have *also* followed the reference
              Severity: Minor
              Found in app/models/concerns/account/merging.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 attempt_oembed has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def attempt_oembed
                  service         = FetchOEmbedService.new
                  url_domain      = Addressable::URI.parse(@url).normalized_host
                  cached_endpoint = Rails.cache.read("oembed_endpoint:#{url_domain}")
              
              
              Severity: Minor
              Found in app/services/fetch_link_card_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 searchable_properties has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def searchable_properties
                  [].tap do |properties|
                    properties << 'image' if ordered_media_attachments.any?(&:image?)
                    properties << 'video' if ordered_media_attachments.any?(&:video?)
                    properties << 'audio' if ordered_media_attachments.any?(&:audio?)
              Severity: Minor
              Found in app/models/concerns/status/search_concern.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 import has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def import
                    authorize :domain_block, :create?
              
                    @import = Admin::Import.new(import_params)
                    return render :new unless @import.validate
              Severity: Minor
              Found in app/controllers/admin/export_domain_blocks_controller.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 process_local_url has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def process_local_url
                  recognized_params = Rails.application.routes.recognize_path(@url)
              
                  case recognized_params[:controller]
                  when 'statuses'
              Severity: Minor
              Found in app/services/resolve_url_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

              Function DropdownSelector has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              export const DropdownSelector: React.FC<Props> = ({
                style,
                items,
                value,
                classNamePrefix = 'privacy-dropdown',
              Severity: Minor
              Found in app/javascript/flavours/glitch/components/dropdown_selector.tsx - 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 modify has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def modify(username)
                    user = Account.find_local(username)&.user
              
                    fail_with_message 'No user with such username' if user.nil?
              
              
              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

              Function DropdownSelector has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              export const DropdownSelector: React.FC<Props> = ({
                style,
                items,
                value,
                classNamePrefix = 'privacy-dropdown',
              Severity: Minor
              Found in app/javascript/mastodon/components/dropdown_selector.tsx - 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

              File action_bar.jsx has 266 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import PropTypes from 'prop-types';
              import { PureComponent } from 'react';
              
              import { defineMessages, injectIntl } from 'react-intl';
              
              
              Severity: Minor
              Found in app/javascript/mastodon/features/status/components/action_bar.jsx - About 2 hrs to fix

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

                  render () {
                    const { status, intl, showReplyCount, withOpenButton } = this.props;
                
                    const publicStatus  = ['public', 'unlisted'].includes(status.get('visibility'));
                    const reblogPrivate = status.getIn(['account', 'id']) === me && status.get('visibility') === 'private';

                  StatusActionBar has 22 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class StatusActionBar extends ImmutablePureComponent {
                    static propTypes = {
                      identity: identityContextPropShape,
                      status: ImmutablePropTypes.map.isRequired,
                      relationship: ImmutablePropTypes.record,
                  Severity: Minor
                  Found in app/javascript/mastodon/components/status_action_bar.jsx - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language