Skip to content

Commit 5c2056a

Browse files
authored
Merge pull request #7 from emizzle/fix/readme
fix: README and env variable warning update
2 parents 7e9d7a1 + d8c415f commit 5c2056a

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ MYTHX_USERNAME="<mythx-username>"
1616
MYTHX_PASSWORD="<password>"
1717
```
1818

19-
> **NOTE:** `MYTHX_ETH_ADDRESS` in favour of `MYTHX_USERNAME` and will be removed in future versions. Please update your .env file or your environment variables accordingly.
19+
> **NOTE:** `MYTHX_ETH_ADDRESS` has been deprecated in favour of `MYTHX_USERNAME` and will be removed in future versions. Please update your .env file or your environment variables accordingly.
2020
2121
`MYTHX_USERNAME` may be either of:
2222
* MythX User ID (assigned by MythX API to any registered user);

mythx.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,49 @@ async function analyse(contracts, cfg, embark) {
2727

2828
if (process.env.MYTHX_ETH_ADDRESS) {
2929
process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS;
30-
embark.logger.warn("The environment variable MYTHX_ETH_ADDRESS in favour of MYTHX_USERNAME and will be removed in future versions. Please update your .env file or your environment variables accordingly.");
30+
embark.logger.warn("The environment variable MYTHX_ETH_ADDRESS has been deprecated in favour of MYTHX_USERNAME and will be removed in future versions. Please update your .env file or your environment variables accordingly.");
3131
}
3232

3333
// Connect to MythX via armlet
34-
if(!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
34+
if (!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
3535
throw new Error("Environment variables 'MYTHX_USERNAME' and 'MYTHX_PASSWORD' not found. Place these in a .env file in the root of your &ETH;App, add them in the CLI command, ie 'MYTHX_USERNAME=xyz MYTHX_PASSWORD=123 embark run', or add them to your system's environment variables.");
3636
}
3737

3838
const armletClient = new armlet.Client(
39-
{
40-
clientToolName: "embark-mythx",
41-
password: process.env.MYTHX_PASSWORD,
42-
ethAddress: process.env.MYTHX_USERNAME,
43-
})
44-
39+
{
40+
clientToolName: "embark-mythx",
41+
password: process.env.MYTHX_PASSWORD,
42+
ethAddress: process.env.MYTHX_USERNAME,
43+
})
44+
4545
// Filter contracts based on parameter choice
4646
let toSubmit = { "contracts": {}, "sources": contracts.sources };
47-
if(!("ignore" in embark.pluginConfig)) {
47+
if (!("ignore" in embark.pluginConfig)) {
4848
embark.pluginConfig.ignore = []
4949
}
5050

5151
for (let [filename, contractObjects] of Object.entries(contracts.contracts)) {
5252
for (let [contractName, contract] of Object.entries(contractObjects)) {
53-
if(!("contracts" in cfg)) {
53+
if (!("contracts" in cfg)) {
5454
if (embark.pluginConfig.ignore.indexOf(contractName) == -1) {
55-
if(!toSubmit.contracts[filename]) {
55+
if (!toSubmit.contracts[filename]) {
5656
toSubmit.contracts[filename] = {}
5757
}
5858
toSubmit.contracts[filename][contractName] = contract;
5959
}
6060
} else {
6161
if (cfg.contracts.indexOf(contractName) >= 0 && embark.pluginConfig.ignore.indexOf(contractName) == -1) {
62-
if(!toSubmit.contracts[filename]) {
62+
if (!toSubmit.contracts[filename]) {
6363
toSubmit.contracts[filename] = {}
6464
}
6565
toSubmit.contracts[filename][contractName] = contract;
6666
}
6767
}
6868
}
6969
}
70-
70+
7171
// Stop here if no contracts are left
72-
if(Object.keys(toSubmit.contracts).length === 0) {
72+
if (Object.keys(toSubmit.contracts).length === 0) {
7373
embark.logger.info("No contracts to submit.");
7474
return 0;
7575
}
@@ -85,12 +85,12 @@ async function getStatus(uuid, embark) {
8585

8686
// Connect to MythX via armlet
8787
const armletClient = new armlet.Client(
88-
{
89-
clientToolName: "embark-mythx",
90-
password: process.env.MYTHX_PASSWORD,
91-
ethAddress: process.env.MYTHX_USERNAME,
92-
})
93-
88+
{
89+
clientToolName: "embark-mythx",
90+
password: process.env.MYTHX_PASSWORD,
91+
ethAddress: process.env.MYTHX_USERNAME,
92+
})
93+
9494
try {
9595
const results = await armletClient.getIssues(uuid);
9696
return ghettoReport(embark.logger, results);
@@ -106,7 +106,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
106106
const initialDelay = ('initial-delay' in config) ? config['initial-delay'] * 1000 : undefined;
107107

108108
const results = await asyncPool(limit, contracts, async buildObj => {
109-
109+
110110
const obj = new MythXIssues(buildObj, config);
111111

112112
let analyzeOpts = {
@@ -118,22 +118,22 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
118118
analyzeOpts.data = mythXUtil.cleanAnalyzeDataEmptyProps(obj.buildObj, config.debug, config.logger.debug);
119119
analyzeOpts.data.analysisMode = config.full ? "full" : "quick";
120120
if (config.debug > 1) {
121-
config.logger.debug("analyzeOpts: " + `${util.inspect(analyzeOpts, {depth: null})}`);
121+
config.logger.debug("analyzeOpts: " + `${util.inspect(analyzeOpts, { depth: null })}`);
122122
}
123123

124124
// request analysis to armlet.
125125
try {
126126
//TODO: Call analyze/analyzeWithStatus asynchronously
127127
config.logger.info("Submitting '" + obj.contractName + "' for " + analyzeOpts.data.analysisMode + " analysis...")
128-
const {issues, status} = await armletClient.analyzeWithStatus(analyzeOpts);
128+
const { issues, status } = await armletClient.analyzeWithStatus(analyzeOpts);
129129
obj.uuid = status.uuid;
130130

131131
if (status.status === 'Error') {
132132
return [status, null];
133133
} else {
134134
obj.setIssues(issues);
135135
}
136-
136+
137137
return [null, obj];
138138
} catch (err) {
139139
//console.log("catch", JSON.stringify(err));
@@ -147,7 +147,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
147147
}
148148

149149
if (errStr.includes('User or default timeout reached after')
150-
|| errStr.includes('Timeout reached after')) {
150+
|| errStr.includes('Timeout reached after')) {
151151
return [(buildObj.contractName + ": ").yellow + errStr, null];
152152
} else {
153153
return [(buildObj.contractName + ": ").red + errStr, null];
@@ -157,7 +157,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
157157
});
158158

159159
return results.reduce((accum, curr) => {
160-
const [ err, obj ] = curr;
160+
const [err, obj] = curr;
161161
if (err) {
162162
accum.errors.push(err);
163163
} else if (obj) {
@@ -172,15 +172,15 @@ function ghettoReport(logger, results) {
172172
results.forEach(ele => {
173173
issuesCount += ele.issues.length;
174174
});
175-
175+
176176
if (issuesCount === 0) {
177177
logger.info('No issues found');
178178
return 0;
179179
}
180180
for (const group of results) {
181181
logger.info(group.sourceList.join(', ').underline);
182182
for (const issue of group.issues) {
183-
logger.info(yaml.safeDump(issue, {'skipInvalid': true}));
183+
logger.info(yaml.safeDump(issue, { 'skipInvalid': true }));
184184
}
185185
}
186186
return 1;

0 commit comments

Comments
 (0)