<commit_before>import {
  SET_STATE, ADD_MESSAGE, UPDATE_MESSAGE, DELETE_MESSAGE
} from './actions';

export default function(state = {messages: []}, action) {
  switch (action.type) {
  case SET_STATE:
    return {messages: action.state};

  case ADD_MESSAGE:
    return {messages: [action.message, ...state.messages]};

  case UPDATE_MESSAGE:
    const newMessages = state.messages.map(candidate => {
        if (candidate.uuid === action.message.uuid) {
          return Object.assign({}, candidate, {
            id: action.message.id,
            url: action.message.url
          });
        }
        return candidate;
    });
    return {messages: newMessages};

  case DELETE_MESSAGE:
    return {
      messages: state.messages.filter(
        candidate => candidate.uuid !== action.message.uuid
      )
    };

  default:
    return state;
  }
}
<commit_msg>Assign messages to state tree using shorthand object assignment<commit_after>import {
  SET_STATE, ADD_MESSAGE, UPDATE_MESSAGE, DELETE_MESSAGE
} from './actions';

export default function(state = {messages: []}, action) {
  switch (action.type) {
  case SET_STATE:
    return {messages: action.state};

  case ADD_MESSAGE:
    return {messages: [action.message, ...state.messages]};

  case UPDATE_MESSAGE:
    const messages = state.messages.map(message => {
        if (message.uuid === action.message.uuid) {
          return Object.assign({}, message, {
            id: action.message.id,
            url: action.message.url
          });
        }
        return candidate;
    });
    return {messages};

  case DELETE_MESSAGE:
    return {
      messages: state.messages.filter(
        message => message.uuid !== action.message.uuid
      )
    };

  default:
    return state;
  }
}

{'fraction_non_alphanumeric': 0.12429057888762769, 'fraction_numerical': 0.0, 'mean_word_length': 2.568825910931174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4893404', 'n_tokens_mistral': 517, 'n_tokens_neox': 500, 'n_words': 119}