Skip to content

Commit

Permalink
Fix existing infractions
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks committed May 12, 2024
1 parent 994dd1d commit b98d469
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 63 deletions.
8 changes: 6 additions & 2 deletions app/lib/legacy-db-snake-case-mappers.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ const { camelCase, knexIdentifierMappers, snakeCase } = require('objection/lib/u
*/
function legacyDbSnakeCaseMappers (opt = {}) {
return knexIdentifierMappers({
parse: (str) => _legacyCamelCase(str, opt),
format: (str) => _legacySnakeCase(str, opt)
parse: (str) => {
return _legacyCamelCase(str, opt)
},
format: (str) => {
return _legacySnakeCase(str, opt)
}
})
}

Expand Down
4 changes: 3 additions & 1 deletion app/models/contact.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class ContactModel extends BaseModel {
this.suffix
]

const onlyPopulatedNameParts = allNameParts.filter((item) => item)
const onlyPopulatedNameParts = allNameParts.filter((item) => {
return item
})

return onlyPopulatedNameParts.join(' ')
}
Expand Down
4 changes: 3 additions & 1 deletion app/models/licence.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ class LicenceModel extends BaseModel {
{ date: this.expiredDate, priority: 3, reason: 'expired' }
]

const filteredDates = endDates.filter((endDate) => endDate.date)
const filteredDates = endDates.filter((endDate) => {
return endDate.date
})

if (filteredDates.length === 0) {
return null
Expand Down
4 changes: 3 additions & 1 deletion app/presenters/bills/view-bill.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function _addressLines (billingAccount) {
address.country
]

return addressParts.filter((part) => part)
return addressParts.filter((part) => {
return part
})
}

function _billRunType (billRun) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ async function go (billRun, billingPeriod, billingAccounts) {
// make that assumption.
const results = await Promise.all(processes)
if (!billRunIsPopulated) {
billRunIsPopulated = results.some((result) => result)
billRunIsPopulated = results.some((result) => {
return result
})
}
}

Expand Down
4 changes: 3 additions & 1 deletion app/services/bill-runs/determine-charge-period.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ function go (chargeVersion, billingPeriod) {
chargeVersion.licence.expiredDate,
chargeVersion.licence.lapsedDate,
chargeVersion.licence.revokedDate
].filter((timestamp) => timestamp)
].filter((timestamp) => {
return timestamp
})

const earliestEndDateTimestamp = Math.min(...endDateTimestamps)

Expand Down
4 changes: 3 additions & 1 deletion app/services/bill-runs/reissue/reissue-bill.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ async function _pauseUntilNotPending (billRunExternalId) {
// bombarding the CM with requests
if (status) {
// Create a new promise that resolves after 1000ms and wait until it's resolved before continuing
await new Promise((resolve) => setTimeout(resolve, 1000))
await new Promise((resolve) => {
return setTimeout(resolve, 1000)
})
}

const result = await ChargingModuleViewBillRunStatusRequest.send(billRunExternalId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ async function go (billingAccountId, licenceId, financialYearEnding) {
* to know only about debits that have not been credited.
*/
function _cleanse (transactions) {
const credits = transactions.filter((transaction) => transaction.credit)
const debits = transactions.filter((transaction) => !transaction.credit)
const credits = transactions.filter((transaction) => {
return transaction.credit
})
const debits = transactions.filter((transaction) => {
return !transaction.credit
})

credits.forEach((credit) => {
const debitIndex = debits.findIndex((debit) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ async function _finaliseBillRun (billRun, accumulatedLicenceIds, resultsOfProces
await UnflagUnbilledLicencesService.go(billRun, allLicenceIds)

// We set `isPopulated` to `true` if at least one processing result was truthy
const isPopulated = resultsOfProcessing.some(result => result)
const isPopulated = resultsOfProcessing.some(result => {
return result
})

// If there are no bill licences then the bill run is considered empty. We just need to set the status to indicate
// this in the UI
Expand Down
12 changes: 6 additions & 6 deletions app/services/health/fetch-import-jobs.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ async function go () {
.from('water_import.job')
.whereIn('state', ['failed', 'completed', 'active', 'created'])
.whereIn('name', PGBOSS_JOBS_ARRAY)
.where((builder) =>
builder
.where((builder) => {
return builder
.where('createdon', '>', currentDateMinusOneDay)
.orWhere('completedon', '>', currentDateMinusOneDay)
)
})
.unionAll(
db
.select(
Expand All @@ -60,11 +60,11 @@ async function go () {
.from('water_import.archive')
.whereIn('state', ['failed', 'completed', 'active', 'created'])
.whereIn('name', PGBOSS_JOBS_ARRAY)
.where((builder) =>
builder
.where((builder) => {
return builder
.where('createdon', '>', currentDateMinusOneDay)
.orWhere('completedon', '>', currentDateMinusOneDay)
)
})
))
.as('jobs')
)
Expand Down
4 changes: 3 additions & 1 deletion app/services/jobs/export/fetch-table-names.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ async function _fetchTableNames (schemaName) {
}

function _pluckTableNames (tableData) {
return tableData.map(obj => obj.table_name)
return tableData.map(obj => {
return obj.table_name
})
}

module.exports = {
Expand Down
4 changes: 3 additions & 1 deletion app/services/plugins/filter-routes.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function _protectedEnvironment (environment) {
}

function _filteredRoutes (routes) {
return routes.filter((route) => !route?.options?.app?.excludeFromProd)
return routes.filter((route) => {
return !route?.options?.app?.excludeFromProd
})
}

module.exports = {
Expand Down
12 changes: 9 additions & 3 deletions db/seeds/01-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async function _insertUsersWhereNotExists (knex) {
}

async function _insertUserGroupsWhereNotExists (knex) {
const seedUsersWithGroups = seedUsers.filter((seedData) => seedData.group)
const seedUsersWithGroups = seedUsers.filter((seedData) => {
return seedData.group
})

for (const seedUser of seedUsersWithGroups) {
const existingUserGroup = await knex('idm.userGroups')
Expand All @@ -121,11 +123,15 @@ async function _updateSeedUsersWithUserIdAndGroupId (knex) {
const groups = await _groups(knex)

seedUsers.forEach((seedUser) => {
const user = users.find(({ userName }) => userName === seedUser.userName)
const user = users.find(({ userName }) => {
return userName === seedUser.userName
})
seedUser.userId = user.userId

if (seedUser.group) {
const userGroup = groups.find(({ group }) => group === seedUser.group)
const userGroup = groups.find(({ group }) => {
return group === seedUser.group
})
seedUser.groupId = userGroup.groupId
}
})
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"seed": "knex seed:run --knexfile knexfile.application.js",
"lint": "eslint $(git diff --name-only --diff-filter=ACMRTUXB | grep -E \"\\.(js)$\")",
"lint:all": "eslint .",
"lint:fix": "eslint --fix .",
"test": "lab --silent-skips --shuffle",
"postinstall": "npm run build",
"version": "npx --yes auto-changelog -p --commit-limit false && git add CHANGELOG.md"
Expand Down
4 changes: 3 additions & 1 deletion test/lib/boom-notifier.lib.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ describe('BoomNotifierLib class', () => {
it('throws a Boom error with the correct message and data', async () => {
const testNotifier = new BoomNotifierLib(id, pinoFake, airbrakeFake)

expect(() => testNotifier.omfg(message, data)).to.throw(Error, { message, data })
expect(() => {
return testNotifier.omfg(message, data)
}).to.throw(Error, { message, data })
})
})
})
8 changes: 6 additions & 2 deletions test/lib/global-notifier.lib.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ describe('GlobalNotifierLib class', () => {
describe('#constructor', () => {
describe("when the 'logger' argument is not provided", () => {
it('throws an error', () => {
expect(() => new GlobalNotifierLib(null, airbrakeFake)).to.throw()
expect(() => {
return new GlobalNotifierLib(null, airbrakeFake)
}).to.throw()
})
})

describe("when the 'notifier' argument is not provided", () => {
it('throws an error', () => {
expect(() => new GlobalNotifierLib(pinoFake)).to.throw()
expect(() => {
return new GlobalNotifierLib(pinoFake)
}).to.throw()
})
})
})
Expand Down
4 changes: 3 additions & 1 deletion test/presenters/base.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ describe('Base presenter', () => {
new Date('2021-10-12T14:41:10.511Z'),
new Date('2021-11-12T14:41:10.511Z'),
new Date('2021-12-12T14:41:10.511Z')
].map(date => BasePresenter.formatChargingModuleDate(date))
].map(date => {
return BasePresenter.formatChargingModuleDate(date)
})

expect(results).to.equal([
'01-JAN-2021',
Expand Down
Loading

0 comments on commit b98d469

Please sign in to comment.