Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Display message when contracts not found
Browse files Browse the repository at this point in the history
  • Loading branch information
daniyarchambylov committed Feb 7, 2019
1 parent e158329 commit 17b3122
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ const doAnalysis = async (client, config, jsonFiles, contractNames = null, rateL
const buildObj = await trufstuf.parseBuildJson(file);

/**
* If contractNames have been passed then skip analyze for unwanted ones.
*/
* If contractNames have been passed then skip analyze for unwanted ones.
*/
if (contractNames && contractNames.indexOf(buildObj.contractName) < 0) {
return [null, null];
}
Expand Down Expand Up @@ -188,7 +188,7 @@ const doAnalysis = async (client, config, jsonFiles, contractNames = null, rateL
}, { errors: [], objects: [] });
};

function doReport(config, objects, errors) {
function doReport(config, objects, errors, notFoundContracts) {
const spaceLimited = ['tap', 'markdown'].indexOf(config.style) === -1;
const eslintIssues = objects
.map(obj => obj.getEslintIssues(spaceLimited))
Expand All @@ -200,6 +200,10 @@ function doReport(config, objects, errors) {
const formatter = getFormatter(config.style);
config.logger.log(formatter(eslintIssuesBtBaseName));

if (notFoundContracts.length > 0) {
config.logger.error(`These smart contracts were not found: ${notFoundContracts.join(', ')}`);
}

if (errors.length > 0) {
config.logger.error('Internal MythX errors encountered:');
errors.forEach(err => {
Expand All @@ -226,6 +230,14 @@ function ghettoReport(logger, results) {
}
}

const getNotFoundContracts = (mythXIssuesObjects, contracts) => {
if (!contracts || contracts.length === 0) {
return [];
}
const mythxContracts = mythXIssuesObjects.map(({ contractName }) => contractName);
return contracts.filter(c => !mythxContracts.includes(c));
}

/**
*
* @param {Object} config - truffle configuration object.
Expand Down Expand Up @@ -278,7 +290,8 @@ async function analyze(config) {
}

const { objects, errors } = await doAnalysis(client, config, jsonFiles, contractNames, rateLimit);
doReport(config, objects, errors);
const notFoundContracts = getNotFoundContracts(objects, contractNames);
doReport(config, objects, errors, notFoundContracts);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/issues2eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MythXIssues {
this.sourceMap = this.buildObj.sourceMap;
this.deployedSourceMap = this.buildObj.deployedSourceMap;
this.offset2InstNum = srcmap.makeOffset2InstNum(this.buildObj.deployedBytecode);

this.contractName = buildObj.contractName;
this.sourceMappingDecoder = new SourceMappingDecoder();
this.asts = this.mapAsts(this.buildObj.sources);
this.lineBreakPositions = this.mapLineBreakPositions(this.sourceMappingDecoder, this.buildObj.sources);
Expand Down

0 comments on commit 17b3122

Please sign in to comment.