Skip to content

Commit

Permalink
update annotation format
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Dec 15, 2023
1 parent 0eae25c commit 9b38a3e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
33 changes: 21 additions & 12 deletions .github/actions/publish-spotbugs-reports/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35350,6 +35350,24 @@ const glob = __nccwpck_require__(3823)
const { XMLParser } = __nccwpck_require__(8396)
const { readFileSync } = __nccwpck_require__(7147)

function bugAnnotation(bug) {
if (Object.hasOwn(bug, 'Method') && !Array.isArray(bug.Method)) {
const title = bug['@_bad_practice']
const message = bug.ShortMessage
const rawDetails = bug.LongMessage
return {
title: title,
message: message,
raw_details: rawDetails,
path: bug.Method.SourceLine['@_relSourcepath'],
start_line: Number(bug.Method.SourceLine['@_start']),
end_line: Number(bug.Method.SourceLine['@_end']),
annotation_level: 'warning',
}
}
return null
}

async function getAnnotations() {
const parseOptions = {
ignoreAttributes: false,
Expand All @@ -35372,18 +35390,9 @@ async function getAnnotations() {
)

for (const bugInstance of data.BugCollection.BugInstance) {
if (
Object.hasOwn(bugInstance, 'Method') &&
!Array.isArray(bugInstance.Method)
) {
annotations.push({
path: bugInstance.Method.SourceLine['@_sourcepath'],
start_line: Number(bugInstance.Method.SourceLine['@_start']),
end_line: Number(bugInstance.Method.SourceLine['@_end']),
annotation_level: 'warning',
title: bugInstance.ShortMessage,
message: bugInstance.LongMessage,
})
const annotation = bugAnnotation(bugInstance)
if (annotation != null) {
annotations.push(annotation)
}
}
}
Expand Down
33 changes: 21 additions & 12 deletions .github/actions/publish-spotbugs-reports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ const glob = require('@actions/glob')
const { XMLParser } = require('fast-xml-parser')
const { readFileSync } = require('fs')

function bugAnnotation(bug) {
if (Object.hasOwn(bug, 'Method') && !Array.isArray(bug.Method)) {
const title = bug['@_bad_practice']
const message = bug.ShortMessage
const rawDetails = bug.LongMessage
return {
title: title,
message: message,
raw_details: rawDetails,
path: bug.Method.SourceLine['@_relSourcepath'],
start_line: Number(bug.Method.SourceLine['@_start']),
end_line: Number(bug.Method.SourceLine['@_end']),
annotation_level: 'warning',
}
}
return null
}

async function getAnnotations() {
const parseOptions = {
ignoreAttributes: false,
Expand All @@ -26,18 +44,9 @@ async function getAnnotations() {
)

for (const bugInstance of data.BugCollection.BugInstance) {
if (
Object.hasOwn(bugInstance, 'Method') &&
!Array.isArray(bugInstance.Method)
) {
annotations.push({
path: bugInstance.Method.SourceLine['@_sourcepath'],
start_line: Number(bugInstance.Method.SourceLine['@_start']),
end_line: Number(bugInstance.Method.SourceLine['@_end']),
annotation_level: 'warning',
title: bugInstance.ShortMessage,
message: bugInstance.LongMessage,
})
const annotation = bugAnnotation(bugInstance)
if (annotation != null) {
annotations.push(annotation)
}
}
}
Expand Down

0 comments on commit 9b38a3e

Please sign in to comment.