mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

  render () {
    const { isLoading, results } = this.props;
    const { type } = this.state;

    let filteredResults = ImmutableList();
Severity: Minor
Found in app/javascript/mastodon/features/explore/results.js - About 45 mins 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 toShortNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function toShortNumber(sourceNumber) {
  if (sourceNumber < DECIMAL_UNITS.THOUSAND) {
    return [sourceNumber, DECIMAL_UNITS.ONE, 0];
  } else if (sourceNumber < DECIMAL_UNITS.MILLION) {
    return [
Severity: Minor
Found in app/javascript/mastodon/utils/numbers.js - About 45 mins 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

Avoid deeply nested control flow statements.
Open

        if (invisible) {
          if (str[i + 1] === '/') { // closing tag
            if (!--invisible) {
              tagChars = tagCharsWithEmojis;
            }
Severity: Major
Found in app/javascript/mastodon/features/emoji/emoji.js - About 45 mins to fix

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

      render () {
        const { attachments, isLoading, hasMore, isAccount, multiColumn, blockedBy, suspended } = this.props;
        const { width } = this.state;
    
        if (!isAccount) {
    Severity: Minor
    Found in app/javascript/mastodon/features/account_gallery/index.js - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { emoji, emojiMap, hovered } = this.props;
    
        if (unicodeMapping[emoji]) {
          const { filename, shortCode } = unicodeMapping[this.props.emoji];

    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 updateReaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const updateReaction = (state, id, name, updater) => state.update('items', list => list.map(announcement => {
      if (announcement.get('id') === id) {
        return announcement.update('reactions', reactions => {
          const idx = reactions.findIndex(reaction => reaction.get('name') === name);
    
    
    Severity: Minor
    Found in app/javascript/mastodon/reducers/announcements.js - About 45 mins 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 relationships has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function relationships(state = initialState, action) {
      switch(action.type) {
      case ACCOUNT_FOLLOW_REQUEST:
        return state.getIn([action.id, 'following']) ? state : state.setIn([action.id, action.locked ? 'requested' : 'following'], true);
      case ACCOUNT_FOLLOW_FAIL:
    Severity: Minor
    Found in app/javascript/mastodon/reducers/relationships.js - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { intl, myAccount, columns, multiColumn, unreadFollowRequests } = this.props;
    
        const navItems = [];
        let height = (multiColumn) ? 0 : 60;
    Severity: Minor
    Found in app/javascript/mastodon/features/getting_started/index.js - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { intl, onPaste, showSearch } = this.props;
        const disabled = this.props.isSubmitting;
    
        let publishText = '';
    Severity: Minor
    Found in app/javascript/mastodon/features/compose/components/compose_form.js - About 45 mins 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 recountUnread has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const recountUnread = (state, last_read_id) => {
      return state.withMutations(mutable => {
        if (compareId(last_read_id, mutable.get('lastReadId')) > 0) {
          mutable.set('lastReadId', last_read_id);
        }
    Severity: Minor
    Found in app/javascript/mastodon/reducers/notifications.js - About 45 mins 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 verify_signature_strength! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def verify_signature_strength!
        raise SignatureVerificationError, 'Mastodon requires the Date header or (created) pseudo-header to be signed' unless signed_headers.include?('date') || signed_headers.include?('(created)')
        raise SignatureVerificationError, 'Mastodon requires the Digest header or (request-target) pseudo-header to be signed' unless signed_headers.include?(Request::REQUEST_TARGET) || signed_headers.include?('digest')
        raise SignatureVerificationError, 'Mastodon requires the Host header to be signed when doing a GET request' if request.get? && !signed_headers.include?('host')
        raise SignatureVerificationError, 'Mastodon requires the Digest header to be signed when doing a POST request' if request.post? && !signed_headers.include?('digest')
    Severity: Minor
    Found in app/controllers/concerns/signature_verification.rb - About 45 mins 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 8 (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 app/models/concerns/account_merging.rb - About 45 mins 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 find_for_oauth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_for_oauth(auth, signed_in_resource = nil)
          # EOLE-SSO Patch
          auth.uid = (auth.uid[0][:uid] || auth.uid[0][:user]) if auth.uid.is_a? Hashie::Array
          identity = Identity.find_for_oauth(auth)
    
    
    Severity: Minor
    Found in app/models/concerns/omniauthable.rb - About 45 mins 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 fetch_resource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_resource(uri, id, on_behalf_of = nil)
        unless id
          json = fetch_resource_without_id_validation(uri, on_behalf_of)
    
          return if !json.is_a?(Hash) || unsupported_uri_scheme?(json['id'])
    Severity: Minor
    Found in app/helpers/jsonld_helper.rb - About 45 mins 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 permitted_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def permitted_for(target_account, account)
          visibility = [:public, :unlisted]
    
          if account.nil?
            where(visibility: visibility).without_local_only
    Severity: Minor
    Found in app/models/status.rb - About 45 mins 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 valid_with_challenge? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def valid_with_challenge?(current_user)
        if current_user.encrypted_password.present?
          errors.add(:current_password, :invalid) unless current_user.valid_password?(current_password)
        else
          errors.add(:current_username, :invalid) unless account.username == current_username
    Severity: Minor
    Found in app/models/form/redirect.rb - About 45 mins 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 [] has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def [](key)
          return super(key) unless rails_initialized?
    
          val = Rails.cache.fetch(cache_key(key, nil)) do
            db_val = object(key)
    Severity: Minor
    Found in app/models/setting.rb - About 45 mins 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 next_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def next_page
        if only_other_accounts?
          # Only consider remote accounts
          return nil if @replies.size < DESCENDANTS_LIMIT
    
    
    Severity: Minor
    Found in app/controllers/activitypub/replies_controller.rb - About 45 mins 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 save_with_challenge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def save_with_challenge(current_user)
        if current_user.encrypted_password.present?
          errors.add(:current_password, :invalid) unless current_user.valid_password?(current_password)
        else
          errors.add(:current_username, :invalid) unless account.username == current_username
    Severity: Minor
    Found in app/models/account_migration.rb - About 45 mins 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 register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def register(status, at_time = Time.now.utc)
        original_status = status.proper
    
        return unless (original_status.public_visibility? && status.public_visibility?) &&
                      !(original_status.account.silenced? || status.account.silenced?) &&
    Severity: Minor
    Found in app/models/trends/links.rb - About 45 mins 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