diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..e1671d6 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,44 @@ +{ + // Define globals exposed by modern browsers. + "browser": false, + + // Define globals exposed by jQuery. + "jquery": false, + + // Define globals exposed by Node.js. + "node": true, + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 2, + + // Prohibit use of a variable before it is defined. + "latedef": true, + + // Enforce line length to 80 characters + "maxlen": 80, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": true, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js index cfb26a7..466736a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,8 +1,20 @@ var gulp = require('gulp'); var yuidoc = require("gulp-yuidoc"); +var jshint = require('gulp-jshint'); +var stylish = require('jshint-stylish'); -gulp.task('default', function() { +gulp.task('lint', function() { + return gulp.src('lib/*.js') + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter(stylish)); +}); + +gulp.task('doc', function() { gulp.src("./lib/*.js") .pipe(yuidoc()) .pipe(gulp.dest("./doc")); +}); + +gulp.task('watch', function() { + gulp.watch("./lib/*.js", ['lint', 'doc']); }); \ No newline at end of file diff --git a/lib/atom.js b/lib/atom.js index 0137bba..bd9b75e 100644 --- a/lib/atom.js +++ b/lib/atom.js @@ -1,3 +1,5 @@ +'use strict'; + var ob = require('./../build/Release/openbabel'); /** @@ -25,7 +27,7 @@ var ob = require('./../build/Release/openbabel'); */ ob.Atom.prototype.isConnectedWith = function (atom, distance) { - if (distance == 1) { + if (distance === 1) { return this.isConnected(atom); } else { this.forEachNeighbour(function (neighbour) { diff --git a/lib/bond.js b/lib/bond.js index 0612c6c..67cf1e4 100644 --- a/lib/bond.js +++ b/lib/bond.js @@ -1,3 +1,5 @@ +'use strict'; + var ob = require('./../build/Release/openbabel'); /** diff --git a/lib/builder.js b/lib/builder.js index c6817ae..b16f0ff 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -1,3 +1,5 @@ +'use strict'; + /** * The Class for 3D Coordinates Builder * diff --git a/lib/conversion.js b/lib/conversion.js index 4643ae2..5460c0a 100644 --- a/lib/conversion.js +++ b/lib/conversion.js @@ -1,3 +1,5 @@ +'use strict'; + /** * The Class for chemical file tables conversion * diff --git a/lib/forcefield.js b/lib/forcefield.js index 7108af1..67f644c 100644 --- a/lib/forcefield.js +++ b/lib/forcefield.js @@ -1,3 +1,5 @@ +'use strict'; + /** * The Class for Force Field * @@ -6,7 +8,8 @@ */ /** - * Setup the forcefield for mol (assigns atom types, charges, etc.). Keep current constraints. + * Setup the forcefield for mol (assigns atom types, charges, etc.). + * Keep current constraints. * * @method setup * @param {Molecule} mol The molecule to be set up @@ -14,30 +17,32 @@ */ /** - * Generate conformers for the molecule (systematicaly rotating torsions). - * - * The initial starting structure here is important, this structure should be - * minimized for the best results. SystematicRotorSearch works by rotating around - * the rotatable bond in a molecule (see OBRotamerList class). This rotating generates - * multiple conformers. The energy for all these conformers is then evaluated and the + * Generate conformers for the molecule + * (systematicaly rotating torsions). + * + * The initial starting structure here is important, + * this structure should be minimized for the best results. + * systematicRotorSearch works by rotating around the rotatable + * bond in a molecule. This rotating generates multiple conformers. + * The energy for all these conformers is then evaluated and the * lowest energy conformer is selected. * * @method systematicRotorSearch - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {ForceField} Returns this */ /** - * Generate conformers for the molecule by systematicaly rotating torsions. To be used in combination with - * systematicRotorSearchNexConformer(). + * Generate conformers for the molecule by systematicaly rotating torsions. + * To be used in combination with systematicRotorSearchNexConformer(). * * @method systematicRotorSearchInitialize - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {Number} The number of conformers * @example * ff.systematicRotorSearchInitialize(300); * while (ff.systematicRotorSearchNextConformer(300)) { - * // do some updating in your program (show last generated conformer, ...) + * // do some updating (show last generated conformer, ...) * } */ @@ -45,7 +50,7 @@ * Evaluate the next conformer. * * @method systematicRotorSearchNextConformer - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {Boolean} Returns true if there are more conformers */ @@ -53,27 +58,28 @@ * Generate conformers for the molecule (randomly rotating torsions). * * The initial starting structure here is important, this structure should be - * minimized for the best results. RandomRotorSearch works by randomly rotating around - * the rotatable bonds in a molecule. + * minimized for the best results. + * randomRotorSearch works by randomly rotating around the rotatable bonds in + * a molecule. * * @method randomRotorSearch - * @param {Number} conformers The number of random conformers to consider during the search. - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} conformers Number of random conformers to consider. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {ForceField} Returns this */ /** - * Generate conformers for the molecule by randomly rotating torsions. To be used in combination with - * randomRotorSearchNexConformer(). + * Generate conformers for the molecule by randomly rotating torsions. + * To be used in combination with randomRotorSearchNexConformer(). * * @method randomRotorSearchInitialize - * @param {Number} conformers The number of random conformers to consider during the search. - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} conformers Number of random conformers to consider. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {ForceField} Returns this * @example * ff.randomRotorSearchInitialize(300); * while (ff.randomRotorSearchNexConformer(300)) { - * // do some updating in your program (show last generated conformer, ...) + * // do some updating (show last generated conformer, ...) * } */ @@ -81,7 +87,7 @@ * Evaluate the next conformer * * @method randomRotorSearchNextConformer - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {Boolean} Returns true if there are more conformers */ @@ -89,8 +95,8 @@ * Generate conformers for the molecule (randomly rotating torsions). * * @method weightedRotorSearch - * @param {Number} conformers The number of random conformers to consider during the search. - * @param {Number} [steps=2500] The number of steps to take during geometry optimization. + * @param {Number} conformers Number of random conformers to consider. + * @param {Number} [steps=2500] Number of steps during geometry optimization. * @return {ForceField} Returns this */ @@ -98,7 +104,7 @@ * Generate conformers for the molecule (randomly rotating torsions). * * @method setLineSearchType - * @param {Number} type The LineSearchType to be used in SteepestDescent and ConjugateGradients. + * @param {Number} type The LineSearchType to be used. * @return {ForceField} Returns this * @example * ff.setLineSearchType(ob.LineSearchType.Newton2Num) @@ -119,14 +125,15 @@ */ /** - * Get the force field formal charges. The formal charges will be added to the atoms of mol as data. + * Get the force field formal charges. The formal charges will be added to + * the atoms of mol as data. * * @method preparePartialCharges * @return {Boolean} Returns true on success */ /** - * Get coordinates for current conformer and attach data with energies, forces, ... to mol. + * Get coordinates for current conformer and attach data to molecule. * * @method getCoordinates * @param {Molecule} mol @@ -134,7 +141,7 @@ */ /** - * Get coordinates for all conformers and attach OBConformerData with energies, forces, ... to mol. + * Get coordinates for all conformers and attach data to molecule. * * @method getConformers * @param {Molecule} mol diff --git a/lib/mol.js b/lib/mol.js index ae9ee3e..99d8208 100644 --- a/lib/mol.js +++ b/lib/mol.js @@ -1,3 +1,5 @@ +'use strict'; + /** * The Class for Molecules * @@ -23,14 +25,14 @@ * Add Hydrogens to the entire molecule to fill out implicit valence spots * * @method addHydrogens - * @param {Boolean} [polarOnly=false] Whether to add Hydrogens only to polar atoms + * @param {Boolean} [polarOnly=false] Whether to add only polar hydrogens * @return {Boolean} Returns true on success */ /** * Delete Hydrogens from the molecule * - * @param {Boolean} [polarOnly=false] Whether to delete Hydrogens only to polar atom + * @param {Boolean} [polarOnly=false] Whether to add only polar hydrogens * @method deleteHydrogens * @return {Boolean} Returns true on success */ diff --git a/lib/openbabel.js b/lib/openbabel.js index 9e06795..779d814 100644 --- a/lib/openbabel.js +++ b/lib/openbabel.js @@ -1,3 +1,5 @@ +'use strict'; + /** * The main module for binding Openbabel to Node.js * diff --git a/lib/vector.js b/lib/vector.js index b788d80..8d454e2 100644 --- a/lib/vector.js +++ b/lib/vector.js @@ -1,3 +1,5 @@ +'use strict'; + var ob = require('./../build/Release/openbabel'); /** diff --git a/package.json b/package.json index e6c7835..dfd548c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openbabel", - "version": "1.0.2", + "version": "1.1.0", "description": "An OpenBabel port for Node.js", "main": "index.js", "scripts": { @@ -26,6 +26,9 @@ "gypfile": true, "devDependencies": { "gulp": "^3.8.10", - "gulp-yuidoc": "^0.1.2" + "gulp-jshint": "^1.9.0", + "gulp-mocha": "^2.0.0", + "gulp-yuidoc": "^0.1.2", + "jshint-stylish": "^1.0.0" } }