Skip to content

Commit 489b4ae

Browse files
committed
Fix the format
1 parent 3b66e77 commit 489b4ae

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/formatters/gitlab.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ function formatFile({ filename, input, output }) {
2828
return differences.map(({ offset, operation, deleteText = '', insertText = '' }) => {
2929
const deleteCode = showInvisibles(deleteText);
3030
const insertCode = showInvisibles(insertText);
31-
const line = input.slice(0, offset).split('\n').length;
31+
const begin = input.slice(0, offset).split('\n').length;
32+
const endOffset = deleteText.split('\n').length - 1;
33+
const end = begin + endOffset;
3234

3335
let message;
3436
// eslint-disable-next-line default-case
@@ -49,11 +51,12 @@ function formatFile({ filename, input, output }) {
4951
check_name: 'prettier',
5052
description: message,
5153
severity: 'minor',
52-
fingerprint: createFingerprint(filename, message, line),
54+
fingerprint: createFingerprint(filename, message, begin, end),
5355
location: {
5456
path: filename,
5557
lines: {
56-
begin: line,
58+
begin,
59+
end,
5760
},
5861
},
5962
};

test/__snapshots__/cli.spec.js.snap

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ exports[`prettier-formatter-gitlab cli should create a code quality report file
1111
"location": {
1212
"path": "test/dirty-2.js",
1313
"lines": {
14-
"begin": 3
14+
"begin": 3,
15+
"end": 3
1516
}
1617
}
1718
},
@@ -24,7 +25,8 @@ exports[`prettier-formatter-gitlab cli should create a code quality report file
2425
"location": {
2526
"path": "test/dirty-2.js",
2627
"lines": {
27-
"begin": 5
28+
"begin": 5,
29+
"end": 5
2830
}
2931
}
3032
},
@@ -37,7 +39,8 @@ exports[`prettier-formatter-gitlab cli should create a code quality report file
3739
"location": {
3840
"path": "test/dirty.js",
3941
"lines": {
40-
"begin": 3
42+
"begin": 3,
43+
"end": 11
4144
}
4245
}
4346
},
@@ -50,7 +53,8 @@ exports[`prettier-formatter-gitlab cli should create a code quality report file
5053
"location": {
5154
"path": "test/dirty.js",
5255
"lines": {
53-
"begin": 12
56+
"begin": 12,
57+
"end": 15
5458
}
5559
}
5660
}

0 commit comments

Comments
 (0)