Passed
Push — master ( beba88...91d9d9 )
by Björn
02:26
created

lib/adapters/specs.js (5 issues)

1
2
var fs          = require('fs');
3
var glob        = require('glob');
4
var globAll     = require('glob-all');
5
var path        = require('path');
6
var extend      = require('util')._extend;
7
var format      = require('string-template');
8
var frontMatter = require('front-matter');
9
var sanatizeType = require('../util/sanatize-patterntype');
10
11
module.exports = function(value, config, cb, pl) {
12
    var data = getPatternSpecs (value, config, pl);
13
    cb(null, processTree(data));
14
}
15
16
module.exports.config = {
17
    verbose: false
18
}
19
20
module.exports.search = function(items, link) {
0 ignored issues
show
The parameter items is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter link is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
21
    var results = [];
22
    // this => collider
23
    /* results.push({
24
        name: name,
25
        type: 'sass ' + type,
26
        description: description,
27
        link: link + hash
28
    }); */
29
30
    return results;
31
}
32
33
34
function getPatternSpecs(value, config, pl) {
0 ignored issues
show
The parameter pl is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter config is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
35
    if (!fs.existsSync(value)) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
36
37
    var sourceFile = frontMatter(fs.readFileSync(value).toString());
38
    if (sourceFile.attributes.pattern && !sourceFile.attributes.pattern.type) {
39
    	// 'type' is not set, try to get it from 'name'
40
    	var parts = String(sourceFile.attributes.pattern.name).split('/');
41
    	if (parts.length > 1) {
42
    		sourceFile.attributes.pattern.type = sanatizeType(parts[0]);
43
    	}
44
    }
45
    return sourceFile.attributes;
46
}
47
48
49
function processTree(tree) {
50
    
51
    // do stuff
52
53
    return tree; //my_stuff;
54
}
55
56