mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

  render () {
    const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
    const { collapsed, animating } = this.state;

    const wrapperClassName = classNames('column-header__wrapper', {
Severity: Minor
Found in app/javascript/mastodon/components/column_header.js - About 3 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 timeAgoString has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export const timeAgoString = (intl, date, now, year, timeGiven, short) => {
  const delta = now - date.getTime();

  let relativeTime;

Severity: Minor
Found in app/javascript/mastodon/components/relative_timestamp.js - About 3 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_s has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def to_s
    return html if custom_emojis.empty? || html.blank?

    i                     = -1
    tag_open_index        = nil
Severity: Minor
Found in app/lib/emoji_formatter.rb - About 3 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 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    let ancestors, descendants;
    const { status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
    const { fullscreen } = this.state;

Severity: Major
Found in app/javascript/mastodon/features/status/index.js - About 3 hrs to fix

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

    const getOrderedLists = createSelector([state => state.get('lists')], lists => {
      if (!lists) {
        return lists;
      }
    
    
    Severity: Major
    Found in app/javascript/mastodon/features/lists/index.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/list_adder/index.js on lines 14..20

    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 106.

    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 4 locations. Consider refactoring.
    Open

              {!columns.some(column => column.get('id') === 'HOME') && (
                <Link to='/home' className='drawer__tab' title={intl.formatMessage(messages.home_timeline)} aria-label={intl.formatMessage(messages.home_timeline)}><Icon id='home' fixedWidth /></Link>
              )}
    Severity: Major
    Found in app/javascript/mastodon/features/compose/index.js and 3 other locations - About 3 hrs to fix
    app/javascript/mastodon/features/compose/index.js on lines 105..107
    app/javascript/mastodon/features/compose/index.js on lines 108..110
    app/javascript/mastodon/features/compose/index.js on lines 111..113

    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 106.

    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 4 locations. Consider refactoring.
    Open

              {!columns.some(column => column.get('id') === 'PUBLIC') && (
                <Link to='/public' className='drawer__tab' title={intl.formatMessage(messages.public)} aria-label={intl.formatMessage(messages.public)}><Icon id='globe' fixedWidth /></Link>
              )}
    Severity: Major
    Found in app/javascript/mastodon/features/compose/index.js and 3 other locations - About 3 hrs to fix
    app/javascript/mastodon/features/compose/index.js on lines 102..104
    app/javascript/mastodon/features/compose/index.js on lines 105..107
    app/javascript/mastodon/features/compose/index.js on lines 108..110

    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 106.

    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 4 locations. Consider refactoring.
    Open

              {!columns.some(column => column.get('id') === 'COMMUNITY') && (
                <Link to='/public/local' className='drawer__tab' title={intl.formatMessage(messages.community)} aria-label={intl.formatMessage(messages.community)}><Icon id='users' fixedWidth /></Link>
              )}
    Severity: Major
    Found in app/javascript/mastodon/features/compose/index.js and 3 other locations - About 3 hrs to fix
    app/javascript/mastodon/features/compose/index.js on lines 102..104
    app/javascript/mastodon/features/compose/index.js on lines 105..107
    app/javascript/mastodon/features/compose/index.js on lines 111..113

    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 106.

    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

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

    const getOrderedLists = createSelector([state => state.get('lists')], lists => {
      if (!lists) {
        return lists;
      }
    
    
    Severity: Major
    Found in app/javascript/mastodon/features/list_adder/index.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/lists/index.js on lines 22..28

    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 106.

    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 4 locations. Consider refactoring.
    Open

              {!columns.some(column => column.get('id') === 'NOTIFICATIONS') && (
                <Link to='/notifications' className='drawer__tab' title={intl.formatMessage(messages.notifications)} aria-label={intl.formatMessage(messages.notifications)}><Icon id='bell' fixedWidth /></Link>
              )}
    Severity: Major
    Found in app/javascript/mastodon/features/compose/index.js and 3 other locations - About 3 hrs to fix
    app/javascript/mastodon/features/compose/index.js on lines 102..104
    app/javascript/mastodon/features/compose/index.js on lines 108..110
    app/javascript/mastodon/features/compose/index.js on lines 111..113

    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 106.

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

      const channelNameToIds = (req, name, params) => new Promise((resolve, reject) => {
        switch (name) {
        case 'user':
          resolve({
            channelIds: channelsForUserStream(req),
    Severity: Major
    Found in streaming/index.js - About 3 hrs to fix

      Class LinkDetailsExtractor has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class LinkDetailsExtractor
        include ActionView::Helpers::TagHelper
        include LanguagesHelper
      
        # Some publications wrap their JSON-LD data in their <script> tags
      Severity: Minor
      Found in app/lib/link_details_extractor.rb - About 3 hrs to fix

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

                <ColumnHeader
                  icon='globe'
                  active={hasUnread}
                  title={intl.formatMessage(messages.title)}
                  onPin={this.handlePin}
        Severity: Major
        Found in app/javascript/mastodon/features/public_timeline/index.js and 1 other location - About 3 hrs to fix
        app/javascript/mastodon/features/community_timeline/index.js on lines 110..121

        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 105.

        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

          handleAccountClick = (e) => {
            if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
              e.preventDefault();
              this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
            }
        app/javascript/mastodon/features/compose/components/quote_indicator.js on lines 32..37

        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 105.

        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

                <ColumnHeader
                  icon='users'
                  active={hasUnread}
                  title={intl.formatMessage(messages.title)}
                  onPin={this.handlePin}
        Severity: Major
        Found in app/javascript/mastodon/features/community_timeline/index.js and 1 other location - About 3 hrs to fix
        app/javascript/mastodon/features/public_timeline/index.js on lines 113..124

        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 105.

        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

          handleAccountClick = (e) => {
            if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
              e.preventDefault();
              this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
            }
        app/javascript/mastodon/features/compose/components/reply_indicator.js on lines 32..37

        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 105.

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

          render () {
            const { status, quote } = this.props;
        
            const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden;
            const renderReadMore = this.props.onClick && status.get('collapsed');
        Severity: Major
        Found in app/javascript/mastodon/components/status_content.js - About 3 hrs to fix

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

            render () {
              const {
                accountId,
                account,
                intl,
          Severity: Major
          Found in app/javascript/mastodon/features/ui/components/report_modal.js - About 3 hrs to fix

            Method discover_endpoint! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              def discover_endpoint!
                return if html.nil?
            
                @format = @options[:format]
                page    = Nokogiri::HTML(html)
            Severity: Minor
            Found in app/services/fetch_oembed_service.rb - About 3 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 patch_for_forwarding! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              def patch_for_forwarding!(original, compacted)
                original.without('@context', 'signature').each do |key, value|
                  next if value.nil? || !compacted.key?(key)
            
                  compacted_value = compacted[key]
            Severity: Minor
            Found in app/helpers/jsonld_helper.rb - About 3 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