How to use the sourcegraph.DiagnosticSeverity function in sourcegraph

To help you get started, we’ve selected a few sourcegraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sourcegraph / sourcegraph / extensions / enterprise / sandbox / src / npmCredentials / providers.ts View on Github external
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
                        })
                    })
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / codeDuplication.ts View on Github external
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
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / travisGo.ts View on Github external
range =>
                                ({
                                    message: 'Outdated Go version used in Travis CI',
                                    range,
                                    severity: sourcegraph.DiagnosticSeverity.Warning,
                                    tags: [TAG_TRAVIS_GO],
                                } as sourcegraph.Diagnostic)
                        )
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / codeOwnership.ts View on Github external
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],
        }
    })
}
github sourcegraph / sourcegraph / extensions / enterprise / sandbox / src / rubyGemDependency / rubyGemDependency.ts View on Github external
return partial.map(partial => ({
                                                      ...partial,
                                                      detail: `see campaign [${context.campaignName}](#)`,
                                                      severity: sourcegraph.DiagnosticSeverity.Warning,
                                                      data: JSON.stringify(dep),
                                                      tags: [DEPENDENCY_TAG, dep.name],
                                                  }))
                                              })
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / packageJsonDependency.ts View on Github external
).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
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / noInlineProps.ts View on Github external
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)
                                )
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / codeOwnership.ts View on Github external
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],
        },
    ]
}
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / importStar.ts View on Github external
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)
                                    )
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / eslint.ts View on Github external
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
    }
}