Skip to content
Permalink
Browse files
Fixed linter 'complexity'
  • Loading branch information
pastorpv committed Nov 26, 2019
1 parent d1f0561 commit 1b32f1b91e4156ca05c49e13272f405290a0d44b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 50 deletions.
@@ -21,16 +21,7 @@ module.exports = class ContentRenderer {

const safeUserRating = {}

if (userPlaylistRating === 1)
safeUserRating.oneStar = true
else if (userPlaylistRating === 2)
safeUserRating.twoStars = true
else if (userPlaylistRating === 3)
safeUserRating.threeStars = true
else if (userPlaylistRating === 4)
safeUserRating.fourStars = true
else if (userPlaylistRating === 5)
safeUserRating.fiveStars = true
this.getRating(safeUserRating, userPlaylistRating)

let finalPlaylistRating = this.sum(playlistRating)
if (finalPlaylistRating > 0)
@@ -51,16 +42,7 @@ module.exports = class ContentRenderer {

upload.safeRating = Math.floor(totalRating)

if (userRating === 1)
upload.oneStar = true
else if (userRating === 2)
upload.twoStars = true
else if (userRating === 3)
upload.threeStars = true
else if (userRating === 4)
upload.fourStars = true
else if (userRating === 5)
upload.fiveStars = true
this.getRating(upload, userRating)

upload.rating = Math.round(totalRating * decimalFactor) / decimalFactor
})
@@ -79,16 +61,7 @@ module.exports = class ContentRenderer {

upload.safeRating = Math.floor(totalRating)

if (userRating === 1)
upload.oneStar = true
else if (userRating === 2)
upload.twoStars = true
else if (userRating === 3)
upload.threeStars = true
else if (userRating === 4)
upload.fourStars = true
else if (userRating === 5)
upload.fiveStars = true
this.getRating(upload, userRating)

upload.rating = Math.round(totalRating * decimalFactor) / decimalFactor
})
@@ -107,16 +80,7 @@ module.exports = class ContentRenderer {

upload.safeRating = Math.floor(totalRating)

if (userRating === 1)
upload.oneStar = true
else if (userRating === 2)
upload.twoStars = true
else if (userRating === 3)
upload.threeStars = true
else if (userRating === 4)
upload.fourStars = true
else if (userRating === 5)
upload.fiveStars = true
this.getRating(upload, userRating)

upload.rating = Math.round(totalRating * decimalFactor) / decimalFactor
})
@@ -134,6 +98,24 @@ module.exports = class ContentRenderer {
}
}

getRating(result, userRating) {
if (userRating === 1)
result.oneStar = true
else if (userRating === 2)
result.twoStars = true
else
this.getRating2(result, userRating)
}

getRating2(result, userRating) {
if (userRating === 3)
result.threeStars = true
else if (userRating === 4)
result.fourStars = true
else if (userRating === 5)
result.fiveStars = true
}

sum(input) {
if (toString.call(input) !== '[object Array]')
return false
@@ -26,23 +26,32 @@ module.exports = class Search {

result.safeRating = Math.floor(totalRating)

if (userRating === 1)
result.oneStar = true
else if (userRating === 2)
result.twoStars = true
else if (userRating === 3)
result.threeStars = true
else if (userRating === 4)
result.fourStars = true
else if (userRating === 5)
result.fiveStars = true
this.getRating(result, userRating)

result.rating = Math.round(totalRating * this.decimalFactor) / this.decimalFactor
})

return searchResult
}

getRating(result, userRating) {
if (userRating === 1)
result.oneStar = true
else if (userRating === 2)
result.twoStars = true
else
this.getRating2(result, userRating)
}

getRating2(result, userRating) {
if (userRating === 3)
result.threeStars = true
else if (userRating === 4)
result.fourStars = true
else if (userRating === 5)
result.fiveStars = true
}

sum(input) {
if (toString.call(input) !== '[object Array]')
return false

0 comments on commit 1b32f1b

Please sign in to comment.