<commit_before>import {
  MAIN_BRICK,
  PRIMITIVE,
  SELECTABLE_PIPE
} from '../../utils/componentNames'

export const evaluate = (workspace, elementId) => {
  const element = workspace.entities[elementId]
  let newUnitTests = workspace.unitTests

  if(element.componentName == SELECTABLE_PIPE) {
    const { input, output } = element
    const inputElement = workspace.entities[input.elementId]

    if(inputElement.componentName == PRIMITIVE) {
      return Object.assign({}, workspace, {
        ...workspace,
        entities: {
          ...workspace.entities,
          [elementId]: {
            ...element,
            type: inputElement.type,
            value: inputElement.value
          }
        }
      })
    }

    if(inputElement.componentName == MAIN_BRICK) {
      const slotIndex = inputElement.inputSlots.findIndex((inputSlot) =>
        inputSlot.id == input.slotId)

      newUnitTests = workspace.unitTests.map((unitTest) => {
        const testInputId = unitTest.testInputIds[slotIndex]
        const testInput = workspace.entities[testInputId]

        return {
          ...unitTest,
          values: {
            ...unitTest.values,
            [elementId]: {
              type: testInput.type,
              value: testInput.value
            }
          }
        }
      })
    }
  }

  return Object.assign({}, workspace, {
    ...workspace,
    unitTests: newUnitTests
  })
}<commit_msg>Single return point in evaluationReducer's 'evaluate'<commit_after>import {
  MAIN_BRICK,
  PRIMITIVE,
  SELECTABLE_PIPE
} from '../../utils/componentNames'

export const evaluate = (workspace, elementId) => {
  const element = workspace.entities[elementId]
  let newEntities = workspace.entities
  let newUnitTests = workspace.unitTests

  if(element.componentName == SELECTABLE_PIPE) {
    const { input, output } = element
    const inputElement = workspace.entities[input.elementId]

    if(inputElement.componentName == PRIMITIVE) {
      newEntities = Object.assign({}, workspace.entities, {
        [elementId]: {
          ...element,
          type: inputElement.type,
          value: inputElement.value
        }
      })
    }

    if(inputElement.componentName == MAIN_BRICK) {
      const slotIndex = inputElement.inputSlots.findIndex((inputSlot) =>
        inputSlot.id == input.slotId)

      newUnitTests = workspace.unitTests.map((unitTest) => {
        const testInputId = unitTest.testInputIds[slotIndex]
        const testInput = workspace.entities[testInputId]

        return {
          ...unitTest,
          values: {
            ...unitTest.values,
            [elementId]: {
              type: testInput.type,
              value: testInput.value
            }
          }
        }
      })
    }
  }

  return Object.assign({}, workspace, {
    ...workspace,
    entities: newEntities,
    unitTests: newUnitTests
  })
}
{'fraction_non_alphanumeric': 0.1137391304347826, 'fraction_numerical': 0.0, 'mean_word_length': 2.1639163916391637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2356768', 'n_tokens_mistral': 824, 'n_tokens_neox': 821, 'n_words': 147}