mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Method modify has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def modify(username)
      user = Account.find_local(username)&.user

      if user.nil?
        say('No user with such username', :red)
Severity: Minor
Found in lib/mastodon/accounts_cli.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 normalizeWheel has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const normalizeWheel = event => {
  // Reasonable defaults
  const PIXEL_STEP = 10;
  const LINE_HEIGHT = 40;
  const PAGE_HEIGHT = 800;
Severity: Major
Found in app/javascript/mastodon/features/ui/components/zoomable_image.js - About 2 hrs to fix

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

    export default function notifications(state = initialState, action) {
      switch(action.type) {
      case MARKERS_FETCH_SUCCESS:
        return action.markers.notifications ? recountUnread(state, action.markers.notifications.last_read_id) : state;
      case NOTIFICATIONS_MOUNT:
    Severity: Major
    Found in app/javascript/mastodon/reducers/notifications.js - About 2 hrs to fix

      Method crawl has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def crawl(start = nil)
            stats           = Concurrent::Hash.new
            processed       = Concurrent::AtomicFixnum.new(0)
            failed          = Concurrent::AtomicFixnum.new(0)
            start_at        = Time.now.to_f
      Severity: Major
      Found in lib/mastodon/domains_cli.rb - About 2 hrs to fix

        Function register has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function register () {
          return (dispatch, getState) => {
            dispatch(setBrowserSupport(supportsPushNotifications));
        
            if (supportsPushNotifications) {
        Severity: Major
        Found in app/javascript/mastodon/actions/push_notifications/registerer.js - About 2 hrs to fix

          Function submitCompose has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function submitCompose(routerHistory) {
            return function (dispatch, getState) {
              const status   = getState().getIn(['compose', 'text'], '');
              const media    = getState().getIn(['compose', 'media_attachments']);
              const statusId = getState().getIn(['compose', 'id'], null);
          Severity: Major
          Found in app/javascript/mastodon/actions/compose.js - About 2 hrs to fix

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

              render () {
                const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
            
                if (loading) {
                  return <div style={{ width: 299 }} />;

              Function statusLists has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function render has 50 lines of code (exceeds 25 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 2 hrs to fix

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

                    render () {
                      const { index, versions, onClose } = this.props;
                      const currentVersion = versions.get(index);
                  
                      const emojiMap = currentVersion.get('emojis').reduce((obj, emoji) => {

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

                      render () {
                        const { media, intl, sensitive, height, defaultWidth, standalone, autoplay, quote } = this.props;
                        const { visible } = this.state;
                    
                        const size     = media.take(9).size;
                    Severity: Minor
                    Found in app/javascript/mastodon/components/media_gallery.js - About 1 hr to fix

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

                        render () {
                          const { accountId, statusIds, featuredStatusIds, isLoading, hasMore, blockedBy, suspended, isAccount, hidden, multiColumn, remote, remoteUrl } = this.props;
                      
                          if (!isAccount) {
                            return (
                      Severity: Minor
                      Found in app/javascript/mastodon/features/account_timeline/index.js - About 1 hr to fix

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

                          render () {
                            const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl } = this.props;
                        
                            if (!isAccount) {
                              return (
                        Severity: Minor
                        Found in app/javascript/mastodon/features/following/index.js - About 1 hr to fix

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

                            render () {
                              const { status, privacy, intl } = this.props;
                              const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog;
                          
                              const visibilityIconInfo = {
                          Severity: Minor
                          Found in app/javascript/mastodon/features/ui/components/boost_modal.js - About 1 hr to fix

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

                              render () {
                                const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl } = this.props;
                            
                                if (!isAccount) {
                                  return (
                            Severity: Minor
                            Found in app/javascript/mastodon/features/followers/index.js - About 1 hr to fix

                              Method remove_statuses has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def remove_statuses
                                    return if options[:skip_status_remove]
                              
                                    say('Creating temporary database indices...')
                              
                              
                              Severity: Minor
                              Found in lib/mastodon/statuses_cli.rb - About 1 hr to fix

                                Function uploadCompose has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function uploadCompose(files) {
                                  return function (dispatch, getState) {
                                    const uploadLimit = 9;
                                    const media  = getState().getIn(['compose', 'media_attachments']);
                                    const pending  = getState().getIn(['compose', 'pending_media_attachments']);
                                Severity: Minor
                                Found in app/javascript/mastodon/actions/compose.js - About 1 hr to fix

                                  Function updateNotifications has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export function updateNotifications(notification, intlMessages, intlLocale) {
                                    return (dispatch, getState) => {
                                      const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
                                      const showInColumn = activeFilter === 'all' ? getState().getIn(['settings', 'notifications', 'shows', notification.type], true) : activeFilter === notification.type;
                                      const showAlert    = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
                                  Severity: Minor
                                  Found in app/javascript/mastodon/actions/notifications.js - About 1 hr to fix

                                    Method deduplicate_users! has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        def deduplicate_users!
                                          remove_index_if_exists!(:users, 'index_users_on_confirmation_token')
                                          remove_index_if_exists!(:users, 'index_users_on_email')
                                          remove_index_if_exists!(:users, 'index_users_on_remember_token')
                                          remove_index_if_exists!(:users, 'index_users_on_reset_password_token')
                                    Severity: Minor
                                    Found in lib/mastodon/maintenance_cli.rb - About 1 hr to fix

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

                                        render () {
                                          const { src, intl, alt, editable, autoPlay, sensitive, blurhash } = this.props;
                                          const { paused, muted, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
                                          const progress = Math.min((currentTime / duration) * 100, 100);
                                      
                                      
                                      Severity: Minor
                                      Found in app/javascript/mastodon/features/audio/index.js - About 1 hr 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