glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Method process_response has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def process_response(response, terminal = false)
    @response_code = response.code
    return nil if response.code != 200

    if valid_activitypub_content_type?(response)
Severity: Minor
Found in app/services/fetch_resource_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 pam_get_user has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def self.pam_get_user(attributes = {})
      return nil unless attributes[:email]

      resource = if Devise.check_at_sign && !attributes[:email].index('@')
                   joins(:account).find_by(accounts: { username: attributes[:email] })
Severity: Minor
Found in app/models/concerns/user/pam_authenticable.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 create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def create(username)
      role_id  = nil

      if options[:role]
        role = UserRole.find_by(name: options[:role])
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 renderItem has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderItem (account, size, index) {
    const { animate } = this.props;

    let width  = 50;
    let height = 100;
Severity: Major
Found in app/javascript/flavours/glitch/components/avatar_composite.jsx - About 2 hrs to fix

    File language_dropdown.jsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

        render () {
          const { intl, hasUnread, columnId, multiColumn, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props;
          const pinned = !!columnId;
          const { signedIn } = this.props.identity;
          const banners = [];
      Severity: Major
      Found in app/javascript/flavours/glitch/features/home_timeline/index.jsx - About 2 hrs to fix

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

          render () {
            const { multiColumn, showNotificationsBadge, unreadNotifications, intl } = this.props;
        
            const elefriend = [glitchedElephant1, glitchedElephant2, glitchedElephant3, elephantUIPlane][this.state.elefriend];
        
        
        Severity: Major
        Found in app/javascript/flavours/glitch/features/compose/index.jsx - About 2 hrs to fix

          Function renderItem has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            renderItem (account, size, index) {
              const { animate } = this.props;
          
              let width  = 50;
              let height = 100;
          Severity: Major
          Found in app/javascript/mastodon/components/avatar_composite.jsx - About 2 hrs to fix

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

              render () {
                const { intl, hasUnread, columnId, multiColumn, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props;
                const pinned = !!columnId;
                const { signedIn } = this.props.identity;
                const banners = [];
            Severity: Major
            Found in app/javascript/mastodon/features/home_timeline/index.jsx - About 2 hrs to fix

              File language_dropdown.jsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

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

                  render () {
                    const { draggingOver } = this.state;
                    const { children, isWide, location, layout, moved } = this.props;
                
                    const className = classNames('ui', {
                Severity: Major
                Found in app/javascript/flavours/glitch/features/ui/index.jsx - About 2 hrs to fix

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

                    render () {
                      const { hasUnread, columnId, multiColumn, list } = this.props;
                      const { id } = this.props.params;
                      const pinned = !!columnId;
                      const title  = list ? list.get('title') : id;
                  Severity: Major
                  Found in app/javascript/flavours/glitch/features/list_timeline/index.jsx - About 2 hrs to fix

                    Function normalizeStatus has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function normalizeStatus(status, normalOldStatus) {
                      const normalStatus   = { ...status };
                      normalStatus.account = status.account.id;
                    
                      if (status.reblog && status.reblog.id) {
                    Severity: Major
                    Found in app/javascript/mastodon/actions/importer/normalizer.js - About 2 hrs to fix

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

                        render () {
                          const { hasUnread, columnId, multiColumn, list } = this.props;
                          const { id } = this.props.params;
                          const pinned = !!columnId;
                          const title  = list ? list.get('title') : id;
                      Severity: Major
                      Found in app/javascript/mastodon/features/list_timeline/index.jsx - About 2 hrs to fix

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

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

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

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

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

                            class StatusActionBar extends ImmutablePureComponent {
                              static propTypes = {
                                identity: identityContextPropShape,
                                status: ImmutablePropTypes.map.isRequired,
                                onReply: PropTypes.func,
                            Severity: Minor
                            Found in app/javascript/flavours/glitch/components/status_action_bar.jsx - About 2 hrs to fix

                              Notification has 21 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              class Notification extends ImmutablePureComponent {
                                static propTypes = {
                                  notification: ImmutablePropTypes.map.isRequired,
                                  hidden: PropTypes.bool,
                                  onMoveUp: PropTypes.func.isRequired,

                                ComposeForm has 21 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                class ComposeForm extends ImmutablePureComponent {
                                  static propTypes = {
                                    intl: PropTypes.object.isRequired,
                                    text: PropTypes.string.isRequired,
                                    suggestions: ImmutablePropTypes.list,

                                  Class SessionsController has 21 methods (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  class Auth::SessionsController < Devise::SessionsController
                                    include Redisable
                                  
                                    MAX_2FA_ATTEMPTS_PER_HOUR = 10
                                  
                                  
                                  Severity: Minor
                                  Found in app/controllers/auth/sessions_controller.rb - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language