<commit_before>var Q = require('q');
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
var SALT_WORK_FACTOR = 10;


var UserSchema = new mongoose.Schema({
  username: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  salt: String,

  firstName: { type: String, default: "Speedee" },
  lastName: { type: String, default: "Gonzales" },
  email: String,
  phone: Number,
  preferredDistance: Number,
  mileSpeed: { type: Number, default: 10 }, // in min/mile
  runs: {type: Array, default: []},

  personalBest: Number, // Personal best in min/mile
  achievements: {type: Object, default: { // Object of all lifetime medals received
    Gold: 0,
    Silver: 0,
    Bronze: 0,
    'High Five': 0,
    Iron: 0, //experimental
  }},
});

UserSchema.methods.comparePasswords = function (candidatePassword) {
  var savedPassword = this.password;
  return Q.Promise(function (resolve, reject) {
    bcrypt.compare(candidatePassword, savedPassword, function (err, isMatch) {
      if (err) {
        reject(err);
      } else {
        resolve(isMatch);
      }
    });
  });
};

UserSchema.pre('save', function (next) {
  var user = this;

  // only hash the password if it has been modified (or is new)
  if (!user.isModified('password')) {
    return next();
  }

  // generate a salt
  bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) {
    if (err) {
      return next(err);<commit_msg>Fix and ungodly number of linter errors<commit_after>var Q = require('q');
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
var SALT_WORK_FACTOR = 10;


var UserSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
    unique: true
  },
  password: {
    type: String,
    required: true
  },
  salt: String,
  firstName: {
    type: String,
    default: "Speedee"
  },
  lastName: {
    type: String,
    default: "Gonzales"
  },
  email: String,
  phone: Number,
  preferredDistance: Number,
  mileSpeed: {
    type: Number,  // in min/mile
    default: 10
  },
  runs: {
    type: Array,
    default: []
  },

  personalBest: Number, // Personal best in min/mile
  achievements: {
    type: Object,
    default: { // Object of all lifetime medals received
      Gold: 0,
      Silver: 0,
      Bronze: 0,
      'High Five': 0,
      Iron: 0 //experimental
    }
  }
});

UserSchema.methods.comparePasswords = function (candidatePassword) {
  var savedPassword = this.password;
  return Q.Promise(function (resolve, reject) {
    bcrypt.compare(candidatePassword, savedPassword, function (err, isMatch) {
      if (err) {
        reject(err);
      } else {
        resolve(isMatch);
      }
    });
  });
};

UserSchema.pre('save', function (next) {
  var user = this;

  // only hash the password if it has been modified (or is new)
  if (!user.isModified('password')) {
    return next();
  }

  // generate a salt
  bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) {
    if (err) {
      return next(err);
{'fraction_non_alphanumeric': 0.13606340819022458, 'fraction_numerical': 0.0059445178335535, 'mean_word_length': 2.9907773386034258, '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': '5970456', 'n_tokens_mistral': 1011, 'n_tokens_neox': 984, 'n_words': 281}