Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return ranges.map(({ range, token }) => {
const diagnostic: sourcegraph.Diagnostic = {
resource: new URL(result.uri),
message: `npm credential committed to source control (\`${token.slice(
0,
4
)}...\`) `,
// detail: 'unable to automatically determine validity (must manually ensure revoked)',
range,
severity: sourcegraph.DiagnosticSeverity.Error,
// eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
data: JSON.stringify({} as DiagnosticData),
tags: [TAG, 'checkbox'],
}
return diagnostic
})
})
const diagnostics: sourcegraph.Diagnostic[] = clones.map(c => {
const numLines = c.duplicationA.end.line - c.duplicationA.start.line
return {
resource: new URL(c.duplicationA.sourceId),
range: duplicationRange(c.duplicationA),
message: `Duplicated code (${numLines} line${numLines !== 1 ? 's' : ''})`,
source: 'codeDuplication',
severity: sourcegraph.DiagnosticSeverity.Information,
relatedInformation: [
{
location: new sourcegraph.Location(
new URL(c.duplicationB.sourceId),
duplicationRange(c.duplicationB)
),
message: 'Duplicated here',
},
],
data: JSON.stringify(c),
tags: [c.format],
check: CHECK_CODE_DUPLICATION,
} as sourcegraph.Diagnostic
})
return diagnostics
range =>
({
message: 'Outdated Go version used in Travis CI',
range,
severity: sourcegraph.DiagnosticSeverity.Warning,
tags: [TAG_TRAVIS_GO],
} as sourcegraph.Diagnostic)
)
return ranges.map(range => {
return {
message: `Independent security review required (PCI-compliant code depends on this file)`,
range,
severity: sourcegraph.DiagnosticSeverity.Error,
data: JSON.stringify({
securityReviewRequired: true,
codeOwner: range.start.line % 2 === 0 ? 'tsenart' : 'keegan',
} as DiagnosticData),
tags: [TAG_CODE_OWNERSHIP_RULES],
}
})
}
return partial.map(partial => ({
...partial,
detail: `see campaign [${context.campaignName}](#)`,
severity: sourcegraph.DiagnosticSeverity.Warning,
data: JSON.stringify(dep),
tags: [DEPENDENCY_TAG, dep.name],
}))
})
).map(({ range, ...dep }) => ({
resource: new URL(uri),
message: `npm dependency '${dep.name}' is deprecated`,
detail: `see campaign [${context.campaignName}](#)`,
range: range,
severity: sourcegraph.DiagnosticSeverity.Warning,
data: JSON.stringify(dep),
tags: [
DEPENDENCY_TAG,
dep.name,
dep.name.replace(/\..*$/, '') /** TODO!(sqs): for lodash */,
],
}))
return diagnostics
range =>
({
message: 'Use named interface Props instead of inline type for consistency',
range,
severity: sourcegraph.DiagnosticSeverity.Information,
data: TAG_NO_INLINE_PROPS,
} as sourcegraph.Diagnostic)
)
function updateDependents(): sourcegraph.Diagnostic[] {
return [
{
message: `Update users of the changed code?`,
severity: sourcegraph.DiagnosticSeverity.Information,
data: JSON.stringify({ updateDependents: true } as DiagnosticData),
tags: [TAG_CODE_OWNERSHIP_RULES],
},
]
}
range =>
({
message:
'Unnecessary `import * as ...` of module that has default export',
range,
severity: sourcegraph.DiagnosticSeverity.Information,
data: JSON.stringify({ binding, module }),
tags: [TAG_IMPORT_STAR],
} as sourcegraph.Diagnostic)
)
function linterSeverityToDiagnosticSeverity(ruleSeverity: Linter.Severity): sourcegraph.DiagnosticSeverity {
switch (ruleSeverity) {
case 0:
return sourcegraph.DiagnosticSeverity.Information
case 1:
return sourcegraph.DiagnosticSeverity.Warning
case 2:
return sourcegraph.DiagnosticSeverity.Error
default:
return sourcegraph.DiagnosticSeverity.Error
}
}