How to use the sourcegraph.CheckResult 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 / check-search / src / dependencyRules.ts View on Github external
}

                    const status: sourcegraph.Status = {
                        title: 'npm dependency security',
                        description: {
                            kind: sourcegraph.MarkupKind.Markdown,
                            value: 'Monitors and enforces rules about the use of npm dependencies.',
                        },
                        state:
                            diagnostics === LOADING
                                ? {
                                      completion: sourcegraph.CheckResult.InProgress,
                                      message: 'Scanning npm dependencies...',
                                  }
                                : {
                                      completion: sourcegraph.CheckResult.Completed,
                                      result:
                                          diagnostics.length > 0
                                              ? sourcegraph.CheckResult.Failure
                                              : sourcegraph.CheckResult.Success,
                                      message:
                                          diagnostics.length > 0
                                              ? 'Unapproved npm dependencies found'
                                              : 'All in-use npm dependencies are approved',
                                  },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Require explicit approval for all npm dependencies`,
                            },
                            notifications: {
                                kind: sourcegraph.MarkupKind.Markdown,
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / eslint.ts View on Github external
const info: sourcegraph.CheckInformation = {
                        description: {
                            kind: sourcegraph.MarkupKind.Markdown,
                            value: 'Checks code using ESLint, an open-source JavaScript linting utility.',
                        },
                        state:
                            diagnostics === LOADING
                                ? {
                                      completion: sourcegraph.CheckCompletion.InProgress,
                                      message: 'Running ESLint...',
                                  }
                                : {
                                      completion: sourcegraph.CheckCompletion.Completed,
                                      result:
                                          diagnostics.length > 0
                                              ? sourcegraph.CheckResult.Failure
                                              : sourcegraph.CheckResult.Success,
                                      message:
                                          diagnostics.length > 0
                                              ? 'ESLint problems found'
                                              : 'Code is compliant with ESLint',
                                  },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `
- Use \`eslint@6.0.1\`
- Check for new, recommended ESLint rules
- Ignore projects with only JavaScript files`,
                            },
                            /*notifications: {
                                kind: sourcegraph.MarkupKind.Markdown,
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / dependencyRules.ts View on Github external
description: {
                            kind: sourcegraph.MarkupKind.Markdown,
                            value: 'Monitors and enforces rules about the use of npm dependencies.',
                        },
                        state:
                            diagnostics === LOADING
                                ? {
                                      completion: sourcegraph.CheckResult.InProgress,
                                      message: 'Scanning npm dependencies...',
                                  }
                                : {
                                      completion: sourcegraph.CheckResult.Completed,
                                      result:
                                          diagnostics.length > 0
                                              ? sourcegraph.CheckResult.Failure
                                              : sourcegraph.CheckResult.Success,
                                      message:
                                          diagnostics.length > 0
                                              ? 'Unapproved npm dependencies found'
                                              : 'All in-use npm dependencies are approved',
                                  },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Require explicit approval for all npm dependencies`,
                            },
                            notifications: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Fail changesets that add unapproved npm dependencies`,
                            },
                        },
                        notifications: sortBy(Array.from(deps.entries()), 0)
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / sampleStatus.ts View on Github external
import * as sourcegraph from 'sourcegraph'
import { Unsubscribable, Subscription } from 'rxjs'

const STATUSES: (sourcegraph.Status & { name: string })[] = [
    {
        name: 'code-churn',
        title: 'Code churn',
        state: {
            completion: sourcegraph.CheckResult.Completed,
            result: sourcegraph.CheckResult.ActionRequired,
            message: 'High code churn detected',
        },
        notifications: [
            { title: 'my notif1', type: sourcegraph.NotificationType.Info },
            { title: 'my notif2', type: sourcegraph.NotificationType.Error },
        ],
    },
]

export function registerSampleStatusProviders(): Unsubscribable {
    const subscriptions = new Subscription()
    for (const status of STATUSES) {
        subscriptions.add(
            sourcegraph.status.registerStatusProvider(status.name, {
                provideStatus: () => status,
            })
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / travisGo.ts View on Github external
switchMap<[URL, sourcegraph.Diagnostic[]][], Promise>(async diagnostics => ({
                        title: 'Travis CI',
                        state: {
                            completion: sourcegraph.CheckResult.Completed,
                            result: sourcegraph.CheckResult.Success,
                            message: 'All builds passing, all repository configuration valid and up-to-date',
                        },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Require all projects to configure Travis CI`,
                            },
                            notifications: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Notify **@sourcegraph/devops** of changes to Travis CI configuration`,
                            },
                        },
                        diagnostics: diagnosticCollection,
                    })),
                    startWith({
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / sampleStatus.ts View on Github external
import * as sourcegraph from 'sourcegraph'
import { Unsubscribable, Subscription } from 'rxjs'

const STATUSES: (sourcegraph.Status & { name: string })[] = [
    {
        name: 'code-churn',
        title: 'Code churn',
        state: {
            completion: sourcegraph.CheckResult.Completed,
            result: sourcegraph.CheckResult.ActionRequired,
            message: 'High code churn detected',
        },
        notifications: [
            { title: 'my notif1', type: sourcegraph.NotificationType.Info },
            { title: 'my notif2', type: sourcegraph.NotificationType.Error },
        ],
    },
]

export function registerSampleStatusProviders(): Unsubscribable {
    const subscriptions = new Subscription()
    for (const status of STATUSES) {
        subscriptions.add(
            sourcegraph.status.registerStatusProvider(status.name, {
                provideStatus: () => status,
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / travisGo.ts View on Github external
switchMap<[URL, sourcegraph.Diagnostic[]][], Promise>(async diagnostics => ({
                        title: 'Travis CI',
                        state: {
                            completion: sourcegraph.CheckResult.Completed,
                            result: sourcegraph.CheckResult.Success,
                            message: 'All builds passing, all repository configuration valid and up-to-date',
                        },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Require all projects to configure Travis CI`,
                            },
                            notifications: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `Notify **@sourcegraph/devops** of changes to Travis CI configuration`,
                            },
                        },
                        diagnostics: diagnosticCollection,
                    })),
                    startWith({
github sourcegraph / sourcegraph / extensions / enterprise / check-search / src / codeDuplication.ts View on Github external
description: {
                            kind: sourcegraph.MarkupKind.Markdown,
                            value:
                                'Checks for code duplication using [**jscpd**](https://github.com/kucherenko/jscpd), a copy-paste detector with support for 150+ languages.',
                        },
                        state:
                            diagnostics === LOADING
                                ? {
                                      completion: sourcegraph.CheckCompletion.InProgress,
                                      message: 'Running jscpd...',
                                  }
                                : {
                                      completion: sourcegraph.CheckCompletion.Completed,
                                      result:
                                          diagnostics.length > 0
                                              ? sourcegraph.CheckResult.Failure
                                              : sourcegraph.CheckResult.Success,
                                      message:
                                          diagnostics.length > 0 ? 'Duplicated code found' : 'No duplicated code found',
                                  },
                        sections: {
                            settings: {
                                kind: sourcegraph.MarkupKind.Markdown,
                                value: `
- Use \`jscpd@2.0.15\`
- Ignore test code
- Ignore vendored code`,
                            },
                        },
                    }
                    return info
                })