mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

  render () {
    const {
      icon,
      items,
      size,
Severity: Major
Found in app/javascript/mastodon/components/dropdown_menu.js - About 2 hrs to fix

    Function getData has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getData(emoji, skin, set) {
      let emojiData = {};
    
      if (typeof emoji === 'string') {
        let matches = emoji.match(COLONS_REGEX);
    Severity: Major
    Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 2 hrs to fix

      Function normalizeStatus has 53 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

        File action_bar.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import PropTypes from 'prop-types';
        import { connect } from 'react-redux';
        import IconButton from '../../../components/icon_button';
        import ImmutablePropTypes from 'react-immutable-proptypes';
        Severity: Minor
        Found in app/javascript/mastodon/features/status/components/action_bar.js - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              const {
                active,
                className,
                disabled,
                expanded,
          Severity: Major
          Found in app/javascript/mastodon/components/icon_button.js and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/components/dropdown_menu.js on lines 298..312

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 77.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  <div className='column-settings__row'>
                    <SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reply']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />} />
                  </div>
          app/javascript/mastodon/features/home_timeline/components/column_settings.js on lines 23..25

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 77.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              const {
                icon,
                items,
                size,
                title,
          Severity: Major
          Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/components/icon_button.js on lines 93..107

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 77.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  <div className='column-settings__row'>
                    <SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show boosts' />} />
                  </div>
          app/javascript/mastodon/features/home_timeline/components/column_settings.js on lines 27..29

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 77.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function StatusTranslation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function StatusTranslation ({ status })  {
            /**
             * @type {string}
             * */
            const locale = document.querySelector('html').getAttribute('lang');
          Severity: Minor
          Found in app/javascript/mastodon/components/status_translation.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 calculate_scores has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def calculate_scores(preview_cards, at_time)
              global_items = []
              locale_items = Hash.new { |h, key| h[key] = [] }
          
              preview_cards.each do |preview_card|
          Severity: Minor
          Found in app/models/trends/links.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 index has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              respond_to do |format|
                format.html do
                  expires_in 0, public: true unless user_signed_in?
          
          
          Severity: Minor
          Found in app/controllers/follower_accounts_controller.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 process_items has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def process_items(items)
              status_ids = items.filter_map do |item|
                uri = value_or_id(item)
                next if ActivityPub::TagManager.instance.local_uri?(uri)
          
          
          Severity: Minor
          Found in app/services/activitypub/fetch_featured_collection_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 parse_and_transform has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_and_transform
              return if @source_html.blank?
          
              parsed_html = Nokogiri::HTML.fragment(@source_html)
          
          
          Severity: Minor
          Found in app/lib/toc_generator.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 call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def call(uri, id: true, prefetched_body: nil, on_behalf_of: nil)
              @json = begin
                if prefetched_body.nil?
                  fetch_resource(uri, id, on_behalf_of)
                else
          Severity: Minor
          Found in app/services/activitypub/fetch_remote_status_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 to has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def to(status)
              case status.visibility
              when 'public'
                [COLLECTIONS[:public]]
              when 'unlisted', 'private'
          Severity: Minor
          Found in app/lib/activitypub/tag_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 preprocess_attributes! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def preprocess_attributes!
              @sensitive    = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
              @text         = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
              @visibility   = @options[:visibility] || @account.user&.setting_default_privacy
              @visibility   = :unlisted if @visibility&.to_sym == :public && @account.silenced?
          Severity: Minor
          Found in app/services/post_status_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 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

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

            def perform
              return if under_load?
          
              budget = compute_budget
              first_policy_id = last_processed_id
          Severity: Minor
          Found in app/workers/scheduler/accounts_statuses_cleanup_scheduler.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 merge_with! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                def merge_with!(other_account)
                  # Since it's the same remote resource, the remote resource likely
                  # already believes we are following/blocking, so it's safe to
                  # re-attribute the relationships too. However, during the presence
                  # of the index bug users could have *also* followed the reference
          Severity: Minor
          Found in lib/mastodon/maintenance_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

          Method create has a Cognitive Complexity of 16 (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/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

          Severity
          Category
          Status
          Source
          Language