<commit_before>import PropTypes from 'prop-types'
import React from 'react'
import { connect as connectFela } from 'react-fela'
import { pipe, length, gt, all, prop, propOr, path, either, complement, not, isNil, isEmpty, tap } from 'ramda'
import Paper from 'material-ui/Paper'
import RaisedButton from 'material-ui/RaisedButton'
import FlatButton from 'material-ui/FlatButton'
import FontIcon from 'material-ui/FontIcon'

import { FormattedMessage } from '../../lib/Intl'
import styles from '../styles/TaskWorker'
import TaskWorkerTree from './TaskWorkerTree'

const getSubTaskPlans = propOr([], 'childTaskPlans')
const getIsTaskComplete = pipe(prop('hasWork'))
const getAreAllSubTasksComplete = pipe(getSubTaskPlans, all(getIsTaskComplete))
const getHasSubTasks = pipe(getSubTaskPlans, childTaskPlans => gt(length(childTaskPlans), 0))
const getIsTaskReadyToComplete = either(complement(getHasSubTasks), getAreAllSubTasksComplete)
const getTaskComponent = path(['taskRecipe', 'Component'])

function TaskWorker (props) {
  const { styles, taskPlan, onNavigate, onComplete, onCancel } = props
  if (isNil(taskPlan)) return null
  const { taskRecipe } = taskPlan
  const { id: taskRecipeId } = taskRecipe
  const childTaskPlans = getSubTaskPlans(taskPlan)
  const hasSubTasks = getHasSubTasks(taskPlan)
  const isTaskComplete = getIsTaskComplete(taskPlan)
  const isTaskReadyToComplete = getIsTaskReadyToComplete(taskPlan)
  const taskComponent = getTaskComponent(taskPlan)
  const Component = isNil(taskComponent)
    ? TaskWorkerTree
    : taskComponent
  const statusIconName = isTaskComplete
    ? 'check-circle'
    : 'circle-o'

  return (
    <div className={styles.container}>
      <Paper
        className={styles.header}
        zDepth={2}
      >
        <FontIcon
          className={`${styles.statusIcon} fa fa-${statusIconName}`}
        />
        <h2 className={styles.taskName}>
          <FormattedMessage
            id={`tasks.recipes.${taskRecipeId}`}
            className={styles.taskNameText}
          />
        </h2>
        <RaisedButton
          primary
          disabled={not(isTaskReadyToComplete)}
          className={styles.completeButton}
          onClick={handleComplete}
          label={
            <FormattedMessage
              id={`tasks.completeTask`}
              className={styles.completeButtonText}
            />
          }
        />
        <FlatButton
          className={styles.cancelButton}
          onClick={handleCancel}
          label={
            <FormattedMessage
              id={`tasks.cancelTask`}
              className={styles.cancelButtonText}
            />
          }
        />
      </Paper>
      <div className={styles.component}>
        <Component
          taskPlan={taskPlan}
          childTaskPlans={childTaskPlans}
          onNavigate={onNavigate}
          onComplete={onComplete}
          onCancel={onCancel}
        />
      </div>
    </div>
  )

  function handleComplete (ev) {
    onComplete(taskPlan)
  }
  function handleCancel (ev) {
    onCancel(taskPlan)
  }
}

export default pipe(
  connectFela(styles)
)(TaskWorker)
<commit_msg>chore(refactor): don't need tap<commit_after>import PropTypes from 'prop-types'
import React from 'react'
import { connect as connectFela } from 'react-fela'
import { pipe, length, gt, all, prop, propOr, path, either, complement, not, isNil, isEmpty } from 'ramda'
import Paper from 'material-ui/Paper'
import RaisedButton from 'material-ui/RaisedButton'
import FlatButton from 'material-ui/FlatButton'
import FontIcon from 'material-ui/FontIcon'

import { FormattedMessage } from '../../lib/Intl'
import styles from '../styles/TaskWorker'
import TaskWorkerTree from './TaskWorkerTree'

const getSubTaskPlans = propOr([], 'childTaskPlans')
const getIsTaskComplete = pipe(prop('hasWork'))
const getAreAllSubTasksComplete = pipe(getSubTaskPlans, all(getIsTaskComplete))
const getHasSubTasks = pipe(getSubTaskPlans, childTaskPlans => gt(length(childTaskPlans), 0))
const getIsTaskReadyToComplete = either(complement(getHasSubTasks), getAreAllSubTasksComplete)
const getTaskComponent = path(['taskRecipe', 'Component'])

function TaskWorker (props) {
  const { styles, taskPlan, onNavigate, onComplete, onCancel } = props
  if (isNil(taskPlan)) return null
  const { taskRecipe } = taskPlan
  const { id: taskRecipeId } = taskRecipe
  const childTaskPlans = getSubTaskPlans(taskPlan)
  const hasSubTasks = getHasSubTasks(taskPlan)
  const isTaskComplete = getIsTaskComplete(taskPlan)
  const isTaskReadyToComplete = getIsTaskReadyToComplete(taskPlan)
  const taskComponent = getTaskComponent(taskPlan)
  const Component = isNil(taskComponent)
    ? TaskWorkerTree
    : taskComponent
  const statusIconName = isTaskComplete
    ? 'check-circle'
    : 'circle-o'

  return (
    <div className={styles.container}>
      <Paper
        className={styles.header}
        zDepth={2}
      >
        <FontIcon
          className={`${styles.statusIcon} fa fa-${statusIconName}`}
        />
        <h2 className={styles.taskName}>
          <FormattedMessage
            id={`tasks.recipes.${taskRecipeId}`}
            className={styles.taskNameText}
          />
        </h2>
        <RaisedButton
          primary
          disabled={not(isTaskReadyToComplete)}
          className={styles.completeButton}
          onClick={handleComplete}
          label={
            <FormattedMessage
              id={`tasks.completeTask`}
              className={styles.completeButtonText}
            />
          }
        />
        <FlatButton
          className={styles.cancelButton}
          onClick={handleCancel}
          label={
            <FormattedMessage
              id={`tasks.cancelTask`}
              className={styles.cancelButtonText}
            />
          }
        />
      </Paper>
      <div className={styles.component}>
        <Component
          taskPlan={taskPlan}
          childTaskPlans={childTaskPlans}
          onNavigate={onNavigate}
          onComplete={onComplete}
          onCancel={onCancel}
        />
      </div>
    </div>
  )

  function handleComplete (ev) {
    onComplete(taskPlan)
  }
  function handleCancel (ev) {
    onCancel(taskPlan)
  }
}

export default pipe(
  connectFela(styles)
)(TaskWorker)

{'fraction_non_alphanumeric': 0.10612569610182976, 'fraction_numerical': 0.0012728719172633255, 'mean_word_length': 2.94601381042059, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '4914585', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1801, 'n_words': 372}