Skip to content

Commit

Permalink
refactor: rename noop to nop for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
PendaGTP committed Jan 20, 2025
1 parent 4eb891b commit 9b2a0d6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions full-sync.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const appFn = require('./')
const { FULL_SYNC_NOOP } = require('./lib/env')
const { FULL_SYNC_NOP } = require('./lib/env')
const { createProbot } = require('probot')

async function performFullSync (appFn, noop) {
async function performFullSync (appFn, nop) {
const probot = createProbot()
probot.log.info(`Starting full sync with NOOP=${noop}`)
probot.log.info(`Starting full sync with NOP=${nop}`)

try {
const app = appFn(probot, {})
const settings = await app.syncInstallation(noop)
const settings = await app.syncInstallation(nop)

if (settings.errors && settings.errors.length > 0) {
probot.log.error('Errors occurred during full sync.')
Expand All @@ -22,7 +22,7 @@ async function performFullSync (appFn, noop) {
}
}

performFullSync(appFn, FULL_SYNC_NOOP).catch((error) => {
performFullSync(appFn, FULL_SYNC_NOP).catch((error) => {
console.error('Fatal error during full sync:', error)
process.exit(1)
})
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
}
}

async function syncInstallation (noop = false) {
async function syncInstallation (nop = false) {
robot.log.trace('Fetching installations')
const github = await robot.auth()

Expand All @@ -249,7 +249,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
log: robot.log,
repo: () => { return { repo: env.ADMIN_REPO, owner: installation.account.login } }
}
return syncAllSettings(noop, context)
return syncAllSettings(nop, context)
}
return null
}
Expand Down
2 changes: 1 addition & 1 deletion lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ module.exports = {
CREATE_PR_COMMENT: process.env.CREATE_PR_COMMENT || 'true',
CREATE_ERROR_ISSUE: process.env.CREATE_ERROR_ISSUE || 'true',
BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false',
FULL_SYNC_NOOP: process.env.FULL_SYNC_NOOP === 'true'
FULL_SYNC_NOP: process.env.FULL_SYNC_NOP === 'true'
}
12 changes: 6 additions & 6 deletions test/unit/lib/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ describe('env', () => {
expect(CREATE_PR_COMMENT).toEqual('true')
})

it('loads default FULL_SYNC_NOOP if not passed', () => {
const FULL_SYNC_NOOP = envTest.FULL_SYNC_NOOP
expect(FULL_SYNC_NOOP).toEqual(false)
it('loads default FULL_SYNC_NOP if not passed', () => {
const FULL_SYNC_NOP = envTest.FULL_SYNC_NOP
expect(FULL_SYNC_NOP).toEqual(false)
})
})

Expand All @@ -42,7 +42,7 @@ describe('env', () => {
process.env.SETTINGS_FILE_PATH = 'safe-settings.yml'
process.env.DEPLOYMENT_CONFIG_FILE = 'safe-settings-deployment.yml'
process.env.CREATE_PR_COMMENT = 'false'
process.env.FULL_SYNC_NOOP = false
process.env.FULL_SYNC_NOP = false
})

it('loads override values if passed', () => {
Expand All @@ -57,8 +57,8 @@ describe('env', () => {
expect(DEPLOYMENT_CONFIG_FILE).toEqual('safe-settings-deployment.yml')
const CREATE_PR_COMMENT = envTest.CREATE_PR_COMMENT
expect(CREATE_PR_COMMENT).toEqual('false')
const FULL_SYNC_NOOP = envTest.FULL_SYNC_NOOP
expect(FULL_SYNC_NOOP).toEqual(false)
const FULL_SYNC_NOP = envTest.FULL_SYNC_NOP
expect(FULL_SYNC_NOP).toEqual(false)
})
})
})
4 changes: 2 additions & 2 deletions test/unit/lib/plugins/branches.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe('Branches', () => {
log.error = jest.fn()

function configure (config) {
const noop = false
const nop = false
const errors = []
return new Branches(noop, github, { owner: 'bkeepers', repo: 'test' }, config, log, errors)
return new Branches(nop, github, { owner: 'bkeepers', repo: 'test' }, config, log, errors)
}

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/plugins/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('Repository', () => {
log.error = jest.fn()

function configure (config) {
const noop = false
const nop = false
const errors = []
return new Repository(noop, github, { owner: 'bkeepers', repo: 'test' }, config, 1, log, errors)
return new Repository(nop, github, { owner: 'bkeepers', repo: 'test' }, config, 1, log, errors)
}

describe('sync', () => {
Expand Down

0 comments on commit 9b2a0d6

Please sign in to comment.