Skip to content

Commit 6caab20

Browse files
authored
Merge pull request #717 from solid/feature/sonarjs
Set up SonarJS static analysis
2 parents b44c444 + 208de8b commit 6caab20

File tree

8 files changed

+517
-25
lines changed

8 files changed

+517
-25
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ addons:
1818
- tim.localhost
1919
- nicola.localhost
2020

21+
script:
22+
- npm run standard
23+
- npm run sonar
24+
- npm run nyc
25+
2126
cache:
2227
apt: true
2328
directories:

bin/lib/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ module.exports = [
277277
return answers.useEmail
278278
},
279279
validate: (value) => {
280-
if (!value || value === '') {
280+
if (!value) {
281281
return 'You must enter this information'
282282
}
283283
return true
@@ -330,7 +330,7 @@ function validPath (value) {
330330
if (value === 'default') {
331331
return Promise.resolve(true)
332332
}
333-
if (!value || value === '') {
333+
if (!value) {
334334
return Promise.resolve('You must enter a valid path')
335335
}
336336
return new Promise((resolve) => {

lib/acl-checker.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class ACLChecker {
4949
const { resource } = this
5050
let isContainer = false
5151
// Create a cascade of reject handlers (one for each possible ACL)
52-
let nearestACL = Promise.reject()
53-
for (const acl of this.getPossibleACLs()) {
54-
nearestACL = nearestACL.catch(() => new Promise((resolve, reject) => {
52+
const nearestACL = this.getPossibleACLs().reduce((prevACL, acl) => {
53+
return prevACL.catch(() => new Promise((resolve, reject) => {
5554
this.fetch(acl, (err, graph) => {
5655
if (err || !graph || !graph.length) {
5756
isContainer = true
@@ -63,7 +62,7 @@ class ACLChecker {
6362
}
6463
})
6564
}))
66-
}
65+
}, Promise.reject())
6766
return nearestACL.catch(e => { throw new Error('No ACL resource found') })
6867
}
6968

lib/handlers/get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ function handler (req, res, next) {
9595
debug(' sending data browser file: ' + dataBrowserPath)
9696
res.sendFile(dataBrowserPath)
9797
return
98-
} else {
98+
} else if (stream) {
9999
res.setHeader('Content-Type', contentType)
100100
return stream.pipe(res)
101101
}
102102
}
103103

104104
// If request accepts the content-type we found
105-
if (negotiator.mediaType([contentType])) {
105+
if (stream && negotiator.mediaType([contentType])) {
106106
res.setHeader('Content-Type', contentType)
107107
if (contentRange) {
108108
const headers = { 'Content-Range': contentRange, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize }

lib/handlers/post.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ function handler (req, res, next) {
3737
}
3838

3939
// Check if container is a directory
40-
if (!stats.isDirectory()) {
40+
if (stats && !stats.isDirectory()) {
4141
debug('Path is not a container, 405!')
4242
return next(error(405, 'Requested resource is not a container'))
4343
}
4444

4545
// Dispatch to the right handler
4646
if (req.is('multipart/form-data')) {
47-
multi(req, res, next)
47+
multi()
4848
} else {
49-
one(req, res, next)
49+
one()
5050
}
5151
})
5252

0 commit comments

Comments
 (0)