Skip to content

Commit

Permalink
fix(authentication-service): fixed sonar code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatdubeysf committed Apr 15, 2021
1 parent e12bb3e commit fad09df
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions packages/custom-sf-changelog/writer-opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const Q = require('q')
const readFile = Q.denodeify(require('fs').readFile)
const resolve = require('path').resolve
const typeMap = {
feat:"Features",
fix:"Bug Fixes",
perf:"Performance Improvements",
revert:"Reverts",
docs:"Documentation",
style:"Styles",
refactor:"Code Refactoring",
test:"Tests",
build:"Build System",
feat: "Features",
fix: "Bug Fixes",
perf: "Performance Improvements",
revert: "Reverts",
docs: "Documentation",
style: "Styles",
refactor: "Code Refactoring",
test: "Tests",
build: "Build System",
ci: "Continuous Integration"
}

Expand All @@ -35,7 +35,7 @@ module.exports = Q.all([
return writerOpts
})

function getWriterOpts () {
function getWriterOpts() {
return {
transform: (commit, context) => {
let discard = true
Expand All @@ -48,7 +48,7 @@ function getWriterOpts () {
if (discard) {
return;
}
if(commit.revert) {
if (commit.revert) {
commit.type = typeMap.revert;
} else {
commit.type = typeMap[commit.type];
Expand Down Expand Up @@ -76,24 +76,12 @@ function getWriterOpts () {
}
if (context.host) {
// User URLs.
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
if (username.includes('/')) {
return `@${username}`
}

return `[@${username}](${context.host}/${username})`
})
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => username.includes('/') ? `@${username}` : `[@${username}](${context.host}/${username})`)
}
}

// remove references that already appear in the subject
commit.references = commit.references.filter(reference => {
if (issues.indexOf(reference.issue) === -1) {
return true
}

return false
})
commit.references = commit.references.filter(reference => issues.indexOf(reference.issue) === -1)

return commit
},
Expand Down

0 comments on commit fad09df

Please sign in to comment.