mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

Method perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(account_id, target_account_uri, relationship, options)
    from_account   = Account.find(account_id)
    target_domain  = domain(target_account_uri)
    target_account = stoplight_wrap_request(target_domain) { ResolveAccountService.new.call(target_account_uri, { check_delivery_availability: true }) }
    options.symbolize_keys!
Severity: Minor
Found in app/workers/import/relationship_worker.rb - 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

Method filter_map has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def filter_map
      if block_given?
        result = []
        each do |element|
          res = yield element
Severity: Minor
Found in lib/enumerable.rb - 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

Method make has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def make
      depth = 8

      # Determine background palette by getting colors close to the image's edge only
      background_palette = palette_from_histogram(convert(':source -alpha set -gravity Center -region 75%x75% -fill None -colorize 100% -alpha transparent +region -format %c -colors :quantity -depth :depth histogram:info:', source: File.expand_path(@file.path), quantity: 10, depth: depth), 10)
Severity: Minor
Found in lib/paperclip/color_extractor.rb - 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

Method perform_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def perform_request(uri, headers: nil)
    return if invalid_origin?(uri)

    req = Request.new(:get, uri)

Severity: Minor
Found in app/lib/activitypub/dereferencer.rb - 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

Function makeGetStatus has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const makeGetStatus = () => {
  return createSelector(
    [
      (state, { id }) => state.getIn(['statuses', id]),
      (state, { id }) => state.getIn(['statuses', state.getIn(['statuses', id, 'reblog'])]),
Severity: Minor
Found in app/javascript/mastodon/selectors/index.js - About 1 hr to fix

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

      render () {
        const { status, intl, withOpenButton } = this.props;
    
        if (status === null) return null
    
    

      Method process_remote_attachments has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def process_remote_attachments
          # IMAGE: [https://s3.mashiro.top/view/2022/02/24/6f3f209aa55e3083f0659ecb62448fc0.jpg]
          image_array = @text.scan(/IMAGE:\s*\[\s*((?:https|http):\/\/.+?)\s*\](?:\s*\{\s*((?:https|http):\/\/.+?)\s*\})*/)
          video_array = @text.scan(/VIDEO:\s*\[\s*((?:https|http):\/\/.+?)\s*\](?:\s*\{\s*((?:https|http):\/\/.+?)\s*\})*/)
      
      
      Severity: Minor
      Found in app/services/post_status_service.rb - About 1 hr to fix

        Function synchronouslySubmitMarkers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
          const accessToken = getState().getIn(['meta', 'access_token'], '');
          const params      = _buildParams(getState());
        
          if (Object.keys(params).length === 0) {
        Severity: Minor
        Found in app/javascript/mastodon/actions/markers.js - About 1 hr to fix

          Function stringFromCodePoint has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const stringFromCodePoint = _String.fromCodePoint || function () {
            let MAX_SIZE = 0x4000;
            let codeUnits = [];
            let highSurrogate;
            let lowSurrogate;
          Severity: Minor
          Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 1 hr to fix

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

              render () {
                const { limit } = this.props;
                const { loading, data } = this.state;
            
                let content;
            Severity: Minor
            Found in app/javascript/mastodon/components/admin/Trends.js - About 1 hr to fix

              Function searchValue has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const searchValue = (value) => {
                    let aPool = pool,
                      aIndex = index,
                      length = 0;
              
              
              Severity: Minor
              Found in app/javascript/mastodon/features/emoji/emoji_mart_search_light.js - About 1 hr to fix

                Function getTicks has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  getTicks (count, size, radius, scaleCoefficient) {
                    const ticks = this.getTickPoints(count);
                    const lesser = 200;
                    const m = [];
                    const bufferLength = this.analyser ? this.analyser.frequencyBinCount : 0;
                Severity: Minor
                Found in app/javascript/mastodon/features/audio/visualizer.js - About 1 hr to fix

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

                    render () {
                      const { category, startedFrom, rules, intl } = this.props;
                  
                      const options = rules.size > 0 ? [
                        'dislike',
                  Severity: Minor
                  Found in app/javascript/mastodon/features/report/category.js - About 1 hr to fix

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

                      render () {
                        const { account, hidden, hideTabs } = this.props;
                    
                        if (account === null) {
                          return null;

                      Method make has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def make
                            metadata = VideoMetadataExtractor.new(@file.path)
                      
                            unless metadata.valid?
                              Paperclip.log("Unsupported file #{@file.path}")
                      Severity: Minor
                      Found in lib/paperclip/transcoder.rb - About 1 hr to fix

                        Method add has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def add(*domains)
                              if domains.empty?
                                say('No domain(s) given', :red)
                                exit(1)
                              end
                        Severity: Minor
                        Found in lib/mastodon/email_domain_blocks_cli.rb - About 1 hr to fix

                          Method remove_orphans_conversations has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def remove_orphans_conversations
                                start_at = Time.now.to_f
                          
                                unless options[:continue] && ActiveRecord::Base.connection.table_exists?('conversations_to_be_deleted')
                                  say('Creating temporary database indices...')
                          Severity: Minor
                          Found in lib/mastodon/statuses_cli.rb - About 1 hr to fix

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

                              _updateStatusLinks () {
                                const node = this.node;
                            
                                if (!node) {
                                  return;
                            Severity: Minor
                            Found in app/javascript/mastodon/components/status_content.js - About 1 hr to fix

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

                                render () {
                                  const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children } = this.props;
                                  const { suggestionsHidden } = this.state;
                              
                                  return [
                              Severity: Minor
                              Found in app/javascript/mastodon/components/autosuggest_textarea.js - About 1 hr to fix

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

                                  render () {
                                    const { announcements, intl } = this.props;
                                    const { index } = this.state;
                                
                                    if (announcements.isEmpty()) {
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language