-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fixes + adding more tests to CPD engine code to make it product…
…ion ready
- Loading branch information
Showing
15 changed files
with
564 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
"CpdViolationMessage": "%s: %s of %s duplication segments detected. %s line(s), %s tokens.", | ||
"CpdViolationMessage": "%s: %s of %s duplication segments detected. %s line(s), %s tokens." | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Builds expected env variables in this format: | ||
* SFDX_SCANNER.<ENGINE>.VARIABLE_NAME | ||
*/ | ||
|
||
import { ENGINE } from "../../Constants"; | ||
|
||
const PREFIX = 'SFDX_SCANNER'; | ||
const SEPARATOR = '_'; | ||
|
||
export enum CONFIG_NAME { | ||
MINIMUM_TOKENS = 'Minimum_Tokens' | ||
} | ||
|
||
function getEnvVariableName(engine: ENGINE, configName: CONFIG_NAME): string { | ||
return `${PREFIX}${SEPARATOR}${engine.toUpperCase()}${SEPARATOR}${configName.toUpperCase()}`; | ||
} | ||
|
||
export function getEnvVariableAsString(engine: ENGINE, configName: CONFIG_NAME): string { | ||
const envVariableName = getEnvVariableName(engine, configName); | ||
return process.env[envVariableName]; | ||
} | ||
|
||
export function getEnvVariableAsNumber(engine: ENGINE, configName: CONFIG_NAME): number { | ||
const envVariable = getEnvVariableAsString(engine, configName); | ||
if (envVariable) { | ||
// Clean up variable if it has any non-digit values | ||
return parseInt(envVariable.replace(/\D/g, ""), 10); | ||
} | ||
return undefined; | ||
} |
Oops, something went wrong.