glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Function normalizeStatus has a Cognitive Complexity of 21 (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 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 filter_from_home has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_from_home(status, receiver_id, crutches, timeline_type = :home)
    return            if receiver_id == status.account_id
    return :filter    if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
    return :skip_home if timeline_type != :list && crutches[:exclusive_list_users][status.account_id].present?
    return :filter    if crutches[:languages][status.account_id].present? && status.language.present? && !crutches[:languages][status.account_id].include?(status.language)
Severity: Minor
Found in app/lib/feed_manager.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 make has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def make
      background_palette, foreground_palette = Rails.configuration.x.use_vips ? palettes_from_libvips : palettes_from_imagemagick

      background_color   = background_palette.first || foreground_palette.first
      foreground_colors  = []
Severity: Minor
Found in lib/paperclip/color_extractor.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 relationshipsReducer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export const relationshipsReducer: Reducer<State> = (
  state = initialState,
  action,
) => {
  if (authorizeFollowRequestSuccess.match(action))
Severity: Minor
Found in app/javascript/flavours/glitch/reducers/relationships.ts - 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 relationshipsReducer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export const relationshipsReducer: Reducer<State> = (
  state = initialState,
  action,
) => {
  if (authorizeFollowRequestSuccess.match(action))
Severity: Minor
Found in app/javascript/mastodon/reducers/relationships.ts - 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 status_content.jsx has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import PropTypes from 'prop-types';
import { PureComponent } from 'react';

import { FormattedMessage, injectIntl } from 'react-intl';

Severity: Minor
Found in app/javascript/flavours/glitch/components/status_content.jsx - About 2 hrs to fix

    File compose_form.jsx has 288 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import PropTypes from 'prop-types';
    import { createRef } from 'react';
    
    import { defineMessages, injectIntl } from 'react-intl';
    
    

      Function notifications has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function notifications(state = initialState, action) {
        let st;
      
        switch(action.type) {
        case fetchMarkers.fulfilled.type:
      Severity: Major
      Found in app/javascript/flavours/glitch/reducers/notifications.js - About 2 hrs to fix

        Method cleanup_concurrent_column_type_change has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def cleanup_concurrent_column_type_change(table, column)
              temp_column = rename_column_name(column)
        
              # Wait for the indices to be built
              indexes_for(table, column).each do |index|
        Severity: Major
        Found in lib/mastodon/migration_helpers.rb - About 2 hrs to fix

          Class ProcessStatusUpdateService has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ActivityPub::ProcessStatusUpdateService < BaseService
            include JsonLdHelper
            include Redisable
            include Lockable
          
          
          Severity: Minor
          Found in app/services/activitypub/process_status_update_service.rb - About 2 hrs to fix

            Function ColumnSettings has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const ColumnSettings: React.FC = () => {
              const settings = useAppSelector((state) => state.settings.get('home'));
            
              const intl = useIntl();
            
            

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

                render () {
                  const { intl, myAccount, columns, multiColumn, unreadFollowRequests, unreadNotifications, lists, openSettings } = this.props;
                  const { signedIn, permissions } = this.props.identity;
              
                  const navItems = [];
              Severity: Major
              Found in app/javascript/flavours/glitch/features/getting_started/index.jsx - About 2 hrs to fix

                Function configFromEnv has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function configFromEnv(env, environment) {
                  /** @type {Record<string, pg.PoolConfig>} */
                  const pgConfigs = {
                    development: {
                      user: env.DB_USER || pg.defaults.user,
                Severity: Major
                Found in streaming/database.js - About 2 hrs to fix

                  Function exports has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = (api) => {
                    const env = api.env();
                  
                    const reactOptions = {
                      development: false,
                  Severity: Major
                  Found in babel.config.js - About 2 hrs to fix

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

                      render () {
                        const { intl, myAccount, columns, multiColumn, unreadFollowRequests, unreadNotifications, lists, openSettings } = this.props;
                        const { signedIn, permissions } = this.props.identity;
                    
                        const navItems = [];
                    Severity: Minor
                    Found in app/javascript/flavours/glitch/features/getting_started/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 20 (exceeds 5 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';

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

                    const normalizeWheel = event => {
                      // Reasonable defaults
                      const PIXEL_STEP = 10;
                      const LINE_HEIGHT = 40;
                      const PAGE_HEIGHT = 800;

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

                    const normalizeWheel = event => {
                      // Reasonable defaults
                      const PIXEL_STEP = 10;
                      const LINE_HEIGHT = 40;
                      const PAGE_HEIGHT = 800;
                    Severity: Minor
                    Found in app/javascript/mastodon/features/ui/components/zoomable_image.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

                    Method build_signed_string has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def build_signed_string(include_query_string: true)
                        signed_headers.map do |signed_header|
                          case signed_header
                          when Request::REQUEST_TARGET
                            if include_query_string
                    Severity: Minor
                    Found in app/controllers/concerns/signature_verification.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 refresh has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def refresh
                          if options[:status]
                            scope = MediaAttachment.where(status_id: options[:status])
                          elsif options[:account]
                            username, domain = options[:account].split('@')
                    Severity: Minor
                    Found in lib/mastodon/cli/media.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

                    Severity
                    Category
                    Status
                    Source
                    Language