Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,30 @@ describe('workspaces source status', () => {
expect(report.diagnostics).toEqual([expect.objectContaining({ code: 'E_PLAN_REF_DELETED' })])
})

it('keeps a key-taken refusal pinned to the folder of a workflow an apply sends by its base', async () => {
mockRequest.mockResolvedValue(
dry(
[{ kind: 'workflow', key: 'ingest', action: 'noop' }],
[
{
code: 'E_NAME_TAKEN',
severity: 'error',
message: 'The workflow key "ingest" belongs to "Other".',
file: 'workflows/ingest/workflow.ts',
kind: 'workflow',
key: 'ingest',
},
]
)
)

await run('status')

const report = printed()
expect(report.plan).toMatchObject({ errors: 1 })
expect(report.diagnostics).toEqual([expect.objectContaining({ code: 'E_NAME_TAKEN' })])
})

it('keeps lint findings on a workflow edited here, which an apply sends whole', async () => {
write('workflows/ingest/workflow.ts', INGEST.replace("'Ingest'", "'Ingest v2'"))
mockRequest.mockResolvedValue(
Expand Down
17 changes: 12 additions & 5 deletions packages/workspace-code/src/diagnostics/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,20 @@ const SHARED_CODE_SET: ReadonlySet<string> = new Set(SHARED_CODES)

/**
* Whether a finding comes from evaluating a workflow folder's files (compile, lint): a workflow
* pipeline code, or one {@link SHARED_CODES} holds pinned to a file. The server reports these only
* for a folder sent whole; a workspace code (a plan check such as `E_PLAN_REF_DELETED`, a held
* reference, a stale resource) can be about any folder, sent whole or by its base.
* pipeline code, or one {@link SHARED_CODES} holds pinned to a line of a file. The server reports
* these only for a folder sent whole; a workspace code (a plan check such as `E_PLAN_REF_DELETED`,
* a held reference, a stale resource) can be about any folder, sent whole or by its base. A
* workspace finding of a shared code points at the resource's file but never at a line in it.
*/
export function isFolderEvaluationFinding(finding: { code: string; file?: string }): boolean {
export function isFolderEvaluationFinding(finding: {
code: string
file?: string
line?: number
}): boolean {
if (OWN_CODE_SET.has(finding.code)) return false
return !SHARED_CODE_SET.has(finding.code) || finding.file !== undefined
return (
!SHARED_CODE_SET.has(finding.code) || (finding.file !== undefined && finding.line !== undefined)
)
}

/**
Expand Down
Loading