<commit_before>import * as React from 'react'

interface IFilesChangedBadgeProps {
  readonly numFilesChanged: number
}

/** The number that can be displayed as a specific value */
const LargeNumber = 300;

/** Displays number of files that have changed */
export class FilesChangedBadge extends React.Component<
  IFilesChangedBadgeProps,
  {}
> {
  private get badgeCount() {
    const numFilesChanged = this.props.numFilesChanged;

    return numFilesChanged > LargeNumber ? `${LargeNumber}+` : numFilesChanged;
  }

  public render() {
    if (!this.props.numFilesChanged) {
      return null;
    }

    return (
      <span className="counter">{this.badgeCount}</span>
    )
  }
}<commit_msg>Follow the engineering values 'Passing values to functions is good'<commit_after>import * as React from 'react'

interface IFilesChangedBadgeProps {
  readonly numFilesChanged: number
}

interface IFilesChangedBadgeState {
  readonly badgeCount: string
}

function createState(props: IFilesChangedBadgeProps): IFilesChangedBadgeState {
  if (props.numFilesChanged === 0) {
    return { badgeCount: '' }
  }

  /** The number that can be displayed as a specific value */
  const LargeNumber = 300
  const badgeCount =
    props.numFilesChanged > LargeNumber ? `${LargeNumber}+` : props.numFilesChanged.toString()

  return { badgeCount }
}

/** Displays number of files that have changed */
export class FilesChangedBadge extends React.Component<
  IFilesChangedBadgeProps,
  IFilesChangedBadgeState
> {
  static getDerivedStateFromProps(props: IFilesChangedBadgeProps): IFilesChangedBadgeState {
    return createState(props)
  }

  public constructor(props: IFilesChangedBadgeProps) {
    super(props)

    this.state = createState(props)
  }

  public render() {
    const badgeCount = this.state.badgeCount

    if (!badgeCount) {
      return null
    }

    return (
      <span className="counter">{badgeCount}</span>
    )
  }
}
{'fraction_non_alphanumeric': 0.0941541645111226, 'fraction_numerical': 0.0036213140196585617, 'mean_word_length': 4.023376623376623, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439261', 'n_tokens_mistral': 577, 'n_tokens_neox': 551, 'n_words': 148}