Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
this.deleteMessages()
const tool: string = (atom.config.get('go-plus.lint.tool'): any)
const cmd = await this.goconfig.locator.findTool(tool)
if (!cmd) {
return
}
const options = this.goconfig.executor.getOptions('file', editor)
let configuredArgs: string | string[] = (atom.config.get(
'go-plus.lint.args'
): any)
if (typeof configuredArgs === 'string') {
configuredArgs = configuredArgs ? argparser(configuredArgs) : []
}
let args = TOOLS[tool.toLowerCase()].prepareArgs(configuredArgs)
args = replaceVariables(args, editor.getPath(), options)
const r: ExecResult = await this.goconfig.executor.exec(cmd, args, options)
if (!r) {
return
}
const stderr = r.stderr instanceof Buffer ? r.stderr.toString() : r.stderr
const stdout = r.stdout instanceof Buffer ? r.stdout.toString() : r.stdout
if (stderr && stderr.trim() !== '') {
console.log(`${tool}-linter: (stderr) ` + stderr) // eslint-disable-line no-console
}
let messages: Array = []
if (stdout && stdout.trim() !== '') {
testCompileArgs(outFile: string, additionalArgs: string = ''): Array {
const result = ['test']
// use additional build args even when we compile the tests
if (additionalArgs && additionalArgs.length) {
const parsed = argparser(additionalArgs)
for (let i = 0; i < parsed.length; i++) {
if (parsed[i] === '-o') {
// we'll take care of this one, skip over the -o flag
i++
continue
} else if (parsed[i] === '-c' || parsed[i] === '-i') {
continue
} else {
result.push(parsed[i])
}
}
}
result.push('-c', '-i', '-o', outFile, '.')
return result
}
async lintInstall(cmd: string, options: ExecutorOptions) {
const command = this.buildCommand(getgopath(), options.cwd || '')
const buildArgs = [command]
let outFile
if (command === 'build') {
outFile = this.outFile()
buildArgs.push('-o')
buildArgs.push(outFile)
}
const additionalArgs = atom.config.get('go-plus.config.additionalBuildArgs')
if (additionalArgs && additionalArgs.length) {
const parsed = argparser(additionalArgs)
buildArgs.push(...parsed)
}
// Include the -i flag with go install.
// See: https://github.com/mdempsky/gocode/issues/79
if (command === 'install' && !buildArgs.includes('-i')) {
buildArgs.push('-i')
}
buildArgs.push('.')
this.output.update({
output: 'Running go ' + buildArgs.join(' '),
exitcode: 0
})
const r = await this.goconfig.executor.exec(cmd, buildArgs, {