mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

  render () {
    const { attachment, displayWidth } = this.props;
    const { visible, loaded } = this.state;

    const width  = `${Math.floor((displayWidth - 4) / 3) - 4}px`;

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 synchronouslySubmitMarkers has a Cognitive Complexity of 15 (exceeds 5 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

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

const mapDispatchToProps = (dispatch, { intl }) => ({

  onChange (path, checked) {
    if (path[0] === 'push') {
      if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {

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

  def safe_for_forwarding?(original, compacted)
    original.without('@context', 'signature').all? do |key, value|
      compacted_value = compacted[key]
      return false unless value.class == compacted_value.class

Severity: Minor
Found in app/helpers/jsonld_helper.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 process_attachments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def process_attachments
    return [] if @object['attachment'].nil?

    media_attachments = []

Severity: Minor
Found in app/lib/activitypub/activity/create.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 open has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def open(host, *args)
        outer_e = nil
        port    = args.first

        addresses = []
Severity: Minor
Found in app/lib/request.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 cc has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def cc(status)
    cc = []

    cc << uri_for(status.reblog.account) if status.reblog?

Severity: Minor
Found in app/lib/activitypub/tag_manager.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 process_remote_attachments has a Cognitive Complexity of 15 (exceeds 5 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

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

  def parse_metadata
    if @metadata.key?(:format)
      @duration = @metadata[:format][:duration].to_f
      @bitrate  = @metadata[:format][:bit_rate].to_i
    end
Severity: Minor
Found in app/lib/video_metadata_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 update_media_attachments! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def update_media_attachments!
    previous_media_attachments     = @status.media_attachments.to_a
    previous_media_attachments_ids = @status.ordered_media_attachment_ids || previous_media_attachments.map(&:id)
    next_media_attachments         = []

Severity: Minor
Found in app/services/activitypub/process_status_update_service.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 pluck_each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def pluck_each(*column_names)
      relation = self

      options = column_names.extract_options!

Severity: Minor
Found in lib/active_record/batches.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 build has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def build(username = nil)
      dry_run = options[:dry_run] ? '(DRY RUN)' : ''

      if options[:all] || username.nil?
        processed, = parallelize_with_progress(Account.joins(:user).merge(User.active)) do |account|
Severity: Minor
Found in lib/mastodon/feeds_cli.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 render has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { statusIds, featuredStatusIds, onLoadMore, timelineId, ...other }  = this.props;
    const { isLoading, isPartial } = other;

    if (isPartial) {
Severity: Minor
Found in app/javascript/mastodon/components/status_list.js - About 1 hr to fix

    Function content has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const content = media.map((image) => {
          const width  = image.getIn(['meta', 'original', 'width']) || null;
          const height = image.getIn(['meta', 'original', 'height']) || null;
    
          if (image.get('type') === 'image') {
    Severity: Minor
    Found in app/javascript/mastodon/features/ui/components/media_modal.js - About 1 hr to fix

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

        render () {
          const { account, notifications, muteDuration, intl } = this.props;
      
          return (
            <div className='modal-root__modal mute-modal'>
      Severity: Minor
      Found in app/javascript/mastodon/features/ui/components/mute_modal.js - About 1 hr to fix

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

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

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

            render () {
              const { columns, children, singleColumn, isModalOpen, intl } = this.props;
              const { shouldAnimate, renderComposePanel } = this.state;
          
              const columnIndex = getIndex(this.context.router.history.location.pathname);
          Severity: Minor
          Found in app/javascript/mastodon/features/ui/components/columns_area.js - About 1 hr to fix

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

              render () {
                const { multiColumn, showSearch, isSearchPage, intl } = this.props;
            
                let header = '';
            
            
            Severity: Minor
            Found in app/javascript/mastodon/features/compose/index.js - About 1 hr to fix

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

                render () {
                  const {
                    intl,
                    statusId,
                    contextType,
              Severity: Minor
              Found in app/javascript/mastodon/features/ui/components/filter_modal.js - About 1 hr to fix

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

                  render () {
                    const { children, mobile } = this.props;
                    const redirect = mobile ? <Redirect from='/' to='/home' exact /> : <Redirect from='/' to='/getting-started' exact />;
                
                    return (
                Severity: Minor
                Found in app/javascript/mastodon/features/ui/index.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language