Fix code quality issues from Copilot review
- Remove duplicated code block (lines 292-304) in check-md-conformance.js - Remove unused variable fenceStartLine in check-md-conformance.js - Remove unused variable hasLanguage in fix-fence-languages.js - Rename fixOpenTicks to fixOpenLine to store full original line
This commit is contained in:
parent
08ac1c1cf3
commit
a953439f08
|
|
@ -80,7 +80,6 @@ function checkFile(filePath) {
|
|||
const violations = [];
|
||||
|
||||
let inFence = false;
|
||||
let fenceStartLine = -1;
|
||||
|
||||
// Pass 1: fence tracking to avoid interpreting list/table inside code blocks
|
||||
const excluded = Array.from({ length: lines.length }).fill(false);
|
||||
|
|
@ -89,10 +88,8 @@ function checkFile(filePath) {
|
|||
if (inFence) {
|
||||
// closing fence
|
||||
inFence = false;
|
||||
fenceStartLine = -1;
|
||||
} else {
|
||||
inFence = true;
|
||||
fenceStartLine = i;
|
||||
}
|
||||
excluded[i] = true;
|
||||
continue;
|
||||
|
|
@ -289,16 +286,3 @@ if (require.main === module) {
|
|||
}
|
||||
|
||||
module.exports = { checkFile };
|
||||
{
|
||||
console.log(`\n- ${path.relative(process.cwd(), file)}`);
|
||||
for (const v of violations) {
|
||||
console.log(` L${v.line.toString().padStart(4, ' ')} ${v.type} ${v.message}`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = { checkFile };
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ function fixFile(filePath) {
|
|||
let fixing = false;
|
||||
let fixFenceStart = -1;
|
||||
let fixOpenIndent = '';
|
||||
let fixOpenTicks = '';
|
||||
let fixOpenLine = '';
|
||||
let fixOpenLen = 0;
|
||||
let fenceContent = [];
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ function fixFile(filePath) {
|
|||
|
||||
fixes.push({
|
||||
line: fixFenceStart + 1,
|
||||
original: fixOpenTicks,
|
||||
original: fixOpenLine,
|
||||
fixed: fixedOpenLine,
|
||||
detectedLanguage: language,
|
||||
contentPreview: fenceContent.slice(0, 2).join('\n').slice(0, 60) + '...',
|
||||
|
|
@ -127,7 +127,7 @@ function fixFile(filePath) {
|
|||
fixing = false;
|
||||
fixFenceStart = -1;
|
||||
fixOpenIndent = '';
|
||||
fixOpenTicks = '';
|
||||
fixOpenLine = '';
|
||||
fixOpenLen = 0;
|
||||
fenceContent = [];
|
||||
continue;
|
||||
|
|
@ -146,7 +146,6 @@ function fixFile(filePath) {
|
|||
const ticksLen = ticks.length;
|
||||
const rest = fenceLineMatch[3] || '';
|
||||
const restTrim = rest.trim();
|
||||
const hasLanguage = restTrim.length > 0; // simplistic but effective for our cases
|
||||
|
||||
// Determine if this is a closing fence for the current outer fence
|
||||
if (fenceStack.length > 0) {
|
||||
|
|
@ -173,7 +172,7 @@ function fixFile(filePath) {
|
|||
fixing = true;
|
||||
fixFenceStart = i;
|
||||
fixOpenIndent = indent;
|
||||
fixOpenTicks = ticks;
|
||||
fixOpenLine = line;
|
||||
fixOpenLen = ticksLen;
|
||||
fenceContent = [];
|
||||
// Do not push the original opening line; we'll emit the fixed one at close
|
||||
|
|
|
|||
Loading…
Reference in New Issue