<commit_before>import React, { Component, PropTypes } from 'react';
import { isBlocked, block } from '../clock';
import { addListener, removeListener } from '../listener';
import blocks from '../blocks';
import { addKeyToStore } from '../redux/actions';
import {
  BACK,
  ESC,
  DOWN,
  ENTER,
  UP,
  MENU,
  INFO,
  REC,
  NEXTPROG,
  PREVPROG,
  SHUTDOWN,
  NUM0,
  NUM1,
  NUM2,
  NUM3,
  NUM4,
  NUM5,
  NUM6,
  NUM7,
  NUM8,
  NUM9,
} from '../keys';
import { execCb } from '../funcHandler';
import { KEYS_TYPE } from '../constants';

class Keys extends Component {

  static get propTypes() {
    return {
      children: React.PropTypes.oneOfType([
        React.PropTypes.object,
        React.PropTypes.array,
      ]),
      id: PropTypes.string.isRequired,
      onBack: PropTypes.func,
      context: PropTypes.object,
      debounce: PropTypes.number,
      onDown: PropTypes.func,
      onEnter: PropTypes.func,
      onUp: PropTypes.func,
      onDigit: PropTypes.func,
      onMenu: PropTypes.func,
      onInfo: PropTypes.func,
      onRec: PropTypes.func,
      onNextProg: PropTypes.func,
      onPrevProg: PropTypes.func,
      onShutDown: PropTypes.func,
      active: PropTypes.bool,
    }
  }

  static get defaultProps() {
    return {
      active: true,
      context: {},
    }
  }

  constructor(props) {
    super(props);
    this.listenerId = addListener(this.keysHandler, this);
  }

  keysHandler(keyCode) {
    if (this.props.active
      && !isBlocked()
      && !blocks.isBlocked(this.props.id)) {
      switch (keyCode) {
        case BACK:
        case ESC:
          this.performAction(this.props.onBack, keyCode);
          break;
        case ENTER:
          this.performAction(this.props.onEnter, keyCode);
          break;
        case UP:
          this.performAction(this.props.onUp, keyCode);
          break;
        case DOWN:
          this.performAction(this.props.onDown, keyCode);
          break;
        case MENU:
          this.performAction(this.props.onMenu, keyCode);
          break;
        case INFO:
          this.performAction(this.props.onInfo, keyCode);
          break;
        case REC:
          this.performAction(this.props.onRec, keyCode);
          break;
        case NEXTPROG:
          this.performAction(this.props.onNextProg, keyCode);
          break;
        case PREVPROG:
          this.performAction(this.props.onPrevProg, keyCode);
          break;
        case SHUTDOWN:
          this.performAction(this.props.onShutDown, keyCode);
          break;
        case NUM0:
        case NUM1:
        case NUM2:
        case NUM3:
        case NUM4:
        case NUM5:
        case NUM6:
        case NUM7:
        case NUM8:
        case NUM9:
          this.performAction(this.props.onDigit, keyCode);
          break;
        default:
          this.performAction(this.props[`on${keyCode}`], keyCode);
      }
    }
  }

  performAction(callback, keyCode) {
    const { debounce, context } = this.props;
    if (callback) {
      block(debounce);
      execCb(callback, keyCode, this, context);
    }
  }

  componentDidMount() {
    addKeyToStore(this.props, KEYS_TYPE);
  }

  componentWillUnmount() {
    removeListener(this.listenerId);
  }

  render() {
    return <div id={this.props.id}>{this.props.children}</div>;
  }
}

export default Keys;<commit_msg>do not return useless div<commit_after>import React, { Component, PropTypes } from 'react';
import { isBlocked, block } from '../clock';
import { addListener, removeListener } from '../listener';
import blocks from '../blocks';
import { addKeyToStore } from '../redux/actions';
import {
  BACK,
  ESC,
  DOWN,
  ENTER,
  UP,
  MENU,
  INFO,
  REC,
  NEXTPROG,
  PREVPROG,
  SHUTDOWN,
  NUM0,
  NUM1,
  NUM2,
  NUM3,
  NUM4,
  NUM5,
  NUM6,
  NUM7,
  NUM8,
  NUM9,
} from '../keys';
import { execCb } from '../funcHandler';
import { KEYS_TYPE } from '../constants';

class Keys extends Component {

  static get propTypes() {
    return {
      children: React.PropTypes.oneOfType([
        React.PropTypes.object,
        React.PropTypes.array,
      ]),
      id: PropTypes.string.isRequired,
      onBack: PropTypes.func,
      context: PropTypes.object,
      debounce: PropTypes.number,
      onDown: PropTypes.func,
      onEnter: PropTypes.func,
      onUp: PropTypes.func,
      onDigit: PropTypes.func,
      onMenu: PropTypes.func,
      onInfo: PropTypes.func,
      onRec: PropTypes.func,
      onNextProg: PropTypes.func,
      onPrevProg: PropTypes.func,
      onShutDown: PropTypes.func,
      active: PropTypes.bool,
    }
  }

  static get defaultProps() {
    return {
      active: true,
      context: {},
    }
  }

  constructor(props) {
    super(props);
    this.listenerId = addListener(this.keysHandler, this);
  }

  keysHandler(keyCode) {
    if (this.props.active
      && !isBlocked()
      && !blocks.isBlocked(this.props.id)) {
      switch (keyCode) {
        case BACK:
        case ESC:
          this.performAction(this.props.onBack, keyCode);
          break;
        case ENTER:
          this.performAction(this.props.onEnter, keyCode);
          break;
        case UP:
          this.performAction(this.props.onUp, keyCode);
          break;
        case DOWN:
          this.performAction(this.props.onDown, keyCode);
          break;
        case MENU:
          this.performAction(this.props.onMenu, keyCode);
          break;
        case INFO:
          this.performAction(this.props.onInfo, keyCode);
          break;
        case REC:
          this.performAction(this.props.onRec, keyCode);
          break;
        case NEXTPROG:
          this.performAction(this.props.onNextProg, keyCode);
          break;
        case PREVPROG:
          this.performAction(this.props.onPrevProg, keyCode);
          break;
        case SHUTDOWN:
          this.performAction(this.props.onShutDown, keyCode);
          break;
        case NUM0:
        case NUM1:
        case NUM2:
        case NUM3:
        case NUM4:
        case NUM5:
        case NUM6:
        case NUM7:
        case NUM8:
        case NUM9:
          this.performAction(this.props.onDigit, keyCode);
          break;
        default:
          this.performAction(this.props[`on${keyCode}`], keyCode);
      }
    }
  }

  performAction(callback, keyCode) {
    const { debounce, context } = this.props;
    if (callback) {
      block(debounce);
      execCb(callback, keyCode, this, context);
    }
  }

  componentDidMount() {
    addKeyToStore(this.props, KEYS_TYPE);
  }

  componentWillUnmount() {
    removeListener(this.listenerId);
  }

  render() {
    return this.props.children || null;
  }
}

export default Keys;
{'fraction_non_alphanumeric': 0.11609814482345901, 'fraction_numerical': 0.005984440454817474, 'mean_word_length': 2.1049698095680447, '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': '6402679', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2150, 'n_words': 443}