<commit_before>import React, { Component, PropTypes } from 'react';
import ItemTypes from './ItemTypes';
import { DragSource, DropTarget } from 'react-dnd';
import flow from 'lodash.flow';

const cardSource = {
  beginDrag(props) {
    return {
      index: props.index,
      originalIndex: props.index
    };
  },

  endDrag(props, monitor) {
    if (props.noDropOutside) {
      const { index, originalIndex } = monitor.getItem();
      const didDrop = monitor.didDrop();

      if (!didDrop) {
        props.moveCard(index, originalIndex);
      }
    }
  }
};

const cardTarget = {
  hover(props, monitor) {
    const dragIndex = monitor.getItem().index;
    const hoverIndex = props.index;

    // Don't replace items with themselves
    if (dragIndex === hoverIndex) {
      return;
    }

    // Time to actually perform the action
    props.moveCard(dragIndex, hoverIndex);

    // Note: we're mutating the monitor item here!
    // Generally it's better to avoid mutations,
    // but it's good here for the sake of performance
    // to avoid expensive index searches.
    monitor.getItem().index = hoverIndex;
  }
};

const propTypes = {
  index: PropTypes.number.isRequired,
  source: PropTypes.any.isRequired,
  createItem: PropTypes.func.isRequired,
  moveCard: PropTypes.func.isRequired,
  isDragging: PropTypes.bool.isRequired,
  connectDragSource: PropTypes.func.isRequired,
  connectDropTarget: PropTypes.func.isRequired,
  noDropOutside: PropTypes.bool
};

class DndCard extends Component {
  render() {
    const {
      index,
      source,
      createItem,
      noDropOutside, // remove from restProps
      moveCard,      // remove from restProps

      isDragging,
      connectDragSource,
      connectDropTarget,
      ...restProps
    } = this.props;

    return connectDragSource(connectDropTarget(
      <div {...restProps}>
        {createItem(source, isDragging)}<commit_msg>Check return value of createItem<commit_after>import React, { Component, PropTypes } from 'react';
import ItemTypes from './ItemTypes';
import { DragSource, DropTarget } from 'react-dnd';
import flow from 'lodash.flow';

const cardSource = {
  beginDrag(props) {
    return {
      index: props.index,
      originalIndex: props.index
    };
  },

  endDrag(props, monitor) {
    if (props.noDropOutside) {
      const { index, originalIndex } = monitor.getItem();
      const didDrop = monitor.didDrop();

      if (!didDrop) {
        props.moveCard(index, originalIndex);
      }
    }
  }
};

const cardTarget = {
  hover(props, monitor) {
    const dragIndex = monitor.getItem().index;
    const hoverIndex = props.index;

    // Don't replace items with themselves
    if (dragIndex === hoverIndex) {
      return;
    }

    // Time to actually perform the action
    props.moveCard(dragIndex, hoverIndex);

    // Note: we're mutating the monitor item here!
    // Generally it's better to avoid mutations,
    // but it's good here for the sake of performance
    // to avoid expensive index searches.
    monitor.getItem().index = hoverIndex;
  }
};

const propTypes = {
  index: PropTypes.number.isRequired,
  source: PropTypes.any.isRequired,
  createItem: PropTypes.func.isRequired,
  moveCard: PropTypes.func.isRequired,
  isDragging: PropTypes.bool.isRequired,
  connectDragSource: PropTypes.func.isRequired,
  connectDropTarget: PropTypes.func.isRequired,
  noDropOutside: PropTypes.bool
};

class DndCard extends Component {
  render() {
    const {
      index,
      source,
      createItem,
      noDropOutside, // remove from restProps
      moveCard,      // remove from restProps

      isDragging,
      connectDragSource,
      connectDropTarget,
      ...restProps
    } = this.props;

    const item = createItem(source, isDragging);
    if (typeof item === 'undefined') {
      console.warn('Warning: createItem returns undefined. It should return a React component or null.');
    }

    return connectDragSource(connectDropTarget(
      <div {...restProps}>
        {createItem(source, isDragging)}
{'fraction_non_alphanumeric': 0.1072313026250619, 'fraction_numerical': 0.0, 'mean_word_length': 2.9481915933528837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3771651', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1164, 'n_words': 311}