Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
Removed useless noop utils function
Browse files Browse the repository at this point in the history
  • Loading branch information
roeldev committed Nov 18, 2015
1 parent 95dab43 commit fbe13c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
6 changes: 5 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ var Utils = require('./lib/utils.js');

var JS_SRC = ['gulpfile.js', 'lib/**/*.js', 'test/*.js'];

function noop()
{
}

////////////////////////////////////////////////////////////////////////////////

Gulp.task('lint', function()
{
return Gulp.src(JS_SRC)
.pipe( GulpJsHint() )
.pipe( GulpJsCs() ).on('error', Utils.noop)
.pipe( GulpJsCs() ).on('error', noop)
.pipe( GulpJsCsStylish.combineWithHintResults() )
.pipe( GulpJsHint.reporter('jshint-stylish') );
});
Expand Down
27 changes: 9 additions & 18 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* confirge | lib/utils.js
* file version: 0.00.005
*/
'use strict';

Expand All @@ -10,21 +9,14 @@ var _ = require('underscore');

var Utils = module.exports =
{
/**
* Empty function.
*/
'noop': function noop()
{
},

/**
* Search for replacements and return a array with each replacement string.
* Returns `false` when no replacements are found.
*
* @param {string} $str - The String to search in.
* @return {array|boolean}
*/
'findReplacements': function findReplacements($str)
findReplacements: function findReplacements($str)
{
var $result = {};
var $found = false;
Expand All @@ -51,7 +43,7 @@ var Utils = module.exports =
* @param {string} $level [''] - The current level
* @return {object} Returns the result object so it can be passed down.
*/
'prepareVar': function prepareVar($result, $vars, $search, $level)
prepareVar: function prepareVar($result, $vars, $search, $level)
{
if (!_.isString($level))
{
Expand Down Expand Up @@ -93,8 +85,7 @@ var Utils = module.exports =
}
}

$result[$level + $search] =
{
$result[$level + $search] = {
'regexp': new RegExp('%' + $level + $search + '%', 'g'),
'replace': $replace
};
Expand All @@ -108,7 +99,7 @@ var Utils = module.exports =
* @param {string} $level [''] - The current level
* @return {object} Returns the result object so it can be passed down.
*/
'prepareVars': function prepareVars($result, $vars, $level)
prepareVars: function prepareVars($result, $vars, $level)
{
if (!_.isString($level))
{
Expand Down Expand Up @@ -146,7 +137,7 @@ var Utils = module.exports =
* @param {object|function} $vars - Object with vars, { varName: value }.
* @return {object|boolean}
*/
'prepareHandleVars': function prepareHandleVars($vars)
prepareHandleVars: function prepareHandleVars($vars)
{
if (_.isFunction($vars))
{
Expand All @@ -171,7 +162,7 @@ var Utils = module.exports =
* @param {object} $vars - The prepared vars to use for the replacements.
* @return {string}
*/
'replaceVars': function replaceVars($str, $vars)
replaceVars: function replaceVars($str, $vars)
{
var $replacements = Utils.findReplacements($str);
var $replacement;
Expand Down Expand Up @@ -207,7 +198,7 @@ var Utils = module.exports =
* @param {object} $vars - Object with prepared vars.
* @return {mixed}
*/
'replaceHandleItem': function replaceHandleItem($value, $vars)
replaceHandleItem: function replaceHandleItem($value, $vars)
{
if (_.isString($value))
{
Expand All @@ -233,7 +224,7 @@ var Utils = module.exports =
* @param {object} $vars - Object with prepared vars.
* @return {array}
*/
'replaceHandleArray': function replaceHandleArray($array, $vars)
replaceHandleArray: function replaceHandleArray($array, $vars)
{
for (var $i = 0, $iL = $array.length; $i < $iL; $i++)
{
Expand All @@ -251,7 +242,7 @@ var Utils = module.exports =
* @param {object} $vars - Object with prepared vars.
* @return {object}
*/
'replaceHandleObject': function replaceHandleObject($obj, $vars)
replaceHandleObject: function replaceHandleObject($obj, $vars)
{
for (var $key in $obj)
{
Expand Down
14 changes: 5 additions & 9 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function getFixtureFile($file, $relative)
return $file;
}

function noop()
{
}

//------------------------------------------------------------------------------

describe('Confirge()', function confirgeTests()
Expand Down Expand Up @@ -278,14 +282,6 @@ describe('Confirge.extend()', function confirgeExtendTests()

//------------------------------------------------------------------------------

describe('Utils.noop()', function utilsNoopTests()
{
it('is only here to get 100% code coverage :P', function()
{
Assert.equal(Utils.noop(), null);
});
});

describe('Utils.findReplacements()', function utilsFindReplacementsTests()
{
it('found replacement [1]', function()
Expand Down Expand Up @@ -606,7 +602,7 @@ describe('Utils.replaceHandleItem()', function utilsReplaceHandleItemTests()

it('should return the exact input value [2]', function()
{
var $input = Utils.noop;
var $input = noop;

Assert.strictEqual(Utils.replaceHandleItem($input, {}), $input);
});
Expand Down

0 comments on commit fbe13c7

Please sign in to comment.