glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

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

  def initialize(path, max_frames = 2)
    @path      = path
    @nb_frames = 0

    File.open(path, 'rb') do |s|
Severity: Minor
Found in lib/paperclip/gif_transcoder.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(*usernames)
      if options[:domain] || options[:all]
        scope  = Account.remote
        scope  = scope.where(domain: options[:domain]) if options[:domain]

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 render has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, footer, emptyMessage, onLoadMore } = this.props;
    const { fullscreen } = this.state;
    const childrenCount = Children.count(children);

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

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

      render () {
        this.updateSketcherSettings();
    
        return (
          <div className='modal-root__modal doodle-modal'>

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

        render () {
          const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, footer, emptyMessage, onLoadMore } = this.props;
          const { fullscreen } = this.state;
          const childrenCount = Children.count(children);
      
      
      Severity: Major
      Found in app/javascript/mastodon/components/scrollable_list.jsx - About 2 hrs to fix

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

          render () {
            const { intl } = this.props;
            const { signedIn, disabledAccountId, permissions } = this.props.identity;
        
            let banner = undefined;
        Severity: Major
        Found in app/javascript/mastodon/features/ui/components/navigation_panel.jsx - About 2 hrs to fix

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

            render() {
              const style = {
                ...this.props.style,
                ...(this.props.active ? this.props.activeStyle : {}),
              };
          Severity: Major
          Found in app/javascript/flavours/glitch/components/icon_button.tsx - About 2 hrs to fix

            File languages_helper.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module LanguagesHelper
              ISO_639_1 = {
                aa: ['Afar', 'Afaraf'].freeze,
                ab: ['Abkhaz', 'аҧсуа бызшәа'].freeze,
                ae: ['Avestan', 'avesta'].freeze,
            Severity: Minor
            Found in app/helpers/languages_helper.rb - About 2 hrs to fix

              File media.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require_relative 'base'
              
              module Mastodon::CLI
                class Media < Base
                  include ActionView::Helpers::NumberHelper
              Severity: Minor
              Found in lib/mastodon/cli/media.rb - About 2 hrs to fix

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

                  render () {
                    const { status, width, height, visible } = this.props;
                    const mediaAttachments = status.get('media_attachments');
                    const language = status.getIn(['language', 'translation']) || status.get('language') || this.props.lang;
                
                
                Severity: Major
                Found in app/javascript/flavours/glitch/components/media_attachments.jsx - About 2 hrs to fix

                  Function makeMapStateToProps has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const makeMapStateToProps = () => {
                    const getStatus = makeGetStatus();
                    const getPictureInPicture = makeGetPictureInPicture();
                  
                    const getAncestorsIds = createSelector([
                  Severity: Major
                  Found in app/javascript/flavours/glitch/features/status/index.jsx - About 2 hrs to fix

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

                      render () {
                        const { status, width, height, visible } = this.props;
                        const mediaAttachments = status.get('media_attachments');
                        const language = status.getIn(['language', 'translation']) || status.get('language') || this.props.lang;
                    
                    
                    Severity: Major
                    Found in app/javascript/mastodon/components/media_attachments.jsx - About 2 hrs to fix

                      Method update_column_in_batches has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def update_column_in_batches(table_name, column, value)
                            if transaction_open?
                              raise 'update_column_in_batches can not be run inside a transaction, ' \
                                'you can disable transactions by calling disable_ddl_transaction! ' \
                                'in the body of your migration class'
                      Severity: Major
                      Found in lib/mastodon/migration_helpers.rb - About 2 hrs to fix

                        Class ApplicationController has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class ApplicationController < ActionController::Base
                          # Prevent CSRF attacks by raising an exception.
                          # For APIs, you may want to use :null_session instead.
                          protect_from_forgery with: :exception
                        
                        
                        Severity: Minor
                        Found in app/controllers/application_controller.rb - About 2 hrs to fix

                          Class AccountAction has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Admin::AccountAction
                            include ActiveModel::Model
                            include AccountableConcern
                            include Authorization
                          
                          
                          Severity: Minor
                          Found in app/models/admin/account_action.rb - About 2 hrs to fix

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

                              render () {
                                const { intl, onOpenSettings } = this.props;
                                const { signedIn, disabledAccountId, permissions } = this.props.identity;
                            
                                let banner = undefined;

                              Function makeMapStateToProps has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const makeMapStateToProps = () => {
                                const getStatus = makeGetStatus();
                                const getPictureInPicture = makeGetPictureInPicture();
                              
                                const getAncestorsIds = createSelector([
                              Severity: Major
                              Found in app/javascript/mastodon/features/status/index.jsx - About 2 hrs to fix

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

                                  render() {
                                    const style = {
                                      ...this.props.style,
                                      ...(this.props.active ? this.props.activeStyle : {}),
                                    };
                                Severity: Major
                                Found in app/javascript/mastodon/components/icon_button.tsx - About 2 hrs to fix

                                  Function _updateStatusLinks has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    _updateStatusLinks () {
                                      const node = this.node;
                                      const { tagLinks, rewriteMentions } = this.props;
                                  
                                      if (!node) {
                                  Severity: Major
                                  Found in app/javascript/flavours/glitch/components/status_content.jsx - About 2 hrs to fix

                                    Function statuses has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export default function statuses(state = initialState, action) {
                                      switch(action.type) {
                                      case STATUS_FETCH_REQUEST:
                                        return state.setIn([action.id, 'isLoading'], true);
                                      case STATUS_FETCH_FAIL:
                                    Severity: Major
                                    Found in app/javascript/flavours/glitch/reducers/statuses.js - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language