<commit_before>var extend = function(definition) {
  var Class = this;

  // Remove transform attribute if it's provided. We don't want to override
  // collection's already set transform function.
  delete definition.transform;

  definition.extend = Class;
  definition.collection = Class.schema.getCollection();

  return Astronomy.Class(definition);
};

var validateDefinition = function(definition) {
  // Check if class definition is provided.
  if (_.isUndefined(definition) || _.isNull(definition)) {
    throw new Error('The class definition has to be provided');
  }
  // Check whether definition is object.
  if (!_.isObject(definition)) {
    throw new Error('The class definition has to be an object');
  }
  // Check if class name is provided.
  if (!_.has(definition, 'name')) {
    throw new Error('The class name has to be provided');
  }
  // Check if class name is a string.
  if (!_.isString(definition.name)) {
    throw new Error('The class name has to be a string');
  }
  // Check if a class with the given name already exists.
  if (_.has(Classes, definition.name)) {
    throw new Error(
      'The class with the name "' + definition.name + '" is already defined'
    );
  }
  // If collection is provided, then check its validity.
  if (_.has(definition, 'collection') &&
    !(definition.collection instanceof Mongo.Collection)) {<commit_msg>Do no require  when extending class<commit_after>var extend = function(definition) {
  var Class = this;

  // Remove `transform` attribute if it's provided. We don't want to override
  // collection's already set transform function.
  delete definition.transform;

  // Add the class from which we want to extend.
  definition.extend = Class;

  // If collection in the parent class was defined, then we want to use this
  // collection in the child class and override it if needed.
  var parentCollection = Class.schema.getCollection();
  if (parentCollection) {
    definition.collection = parentCollection;
  }

  return Astronomy.Class(definition);
};

var validateDefinition = function(definition) {
  // Check if class definition is provided.
  if (_.isUndefined(definition) || _.isNull(definition)) {
    throw new Error('The class definition has to be provided');
  }
  // Check whether definition is object.
  if (!_.isObject(definition)) {
    throw new Error('The class definition has to be an object');
  }
  // Check if class name is provided.
  if (!_.has(definition, 'name')) {
    throw new Error('The class name has to be provided');
  }
  // Check if class name is a string.
  if (!_.isString(definition.name)) {
    throw new Error('The class name has to be a string');
  }
  // Check if a class with the given name already exists.
  if (_.has(Classes, definition.name)) {
    throw new Error(
      'The class with the name "' + definition.name +
      '" is already defined'
    );
  }
  // If collection is provided, then check its validity.
  if (_.has(definition, 'collection') &&
    !(definition.collection instanceof Mongo.Collection)) {
{'fraction_non_alphanumeric': 0.10836627140974966, 'fraction_numerical': 0.0, 'mean_word_length': 3.4014492753623187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6760246', 'n_tokens_mistral': 821, 'n_tokens_neox': 801, 'n_words': 331}