@iobroker/repochecker 5.5.2 → 5.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,13 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.5.4 (2026-03-22)
29
+ - (@copilot) Fixed E6015/W6016 false positives: German (and English) language detection now ignores fenced code blocks, inline code, blockquote lines, link URLs, and image markup before analyzing the README text.
30
+
31
+ ### 5.5.3 (2026-03-19)
32
+ - (@copilot) Fixed E3016 false positive: transitive `needs` dependencies are now considered, so `deploy` depending on `adapter-tests` which already depends on `check-and-lint` is correctly accepted. Related to [#756].
33
+ - (@copilot) W5041 warning now includes the list of languages that contain the example keys (e.g. `languages: en, de, ru`).
34
+
28
35
  ### 5.5.2 (2026-03-17)
29
36
  - (@copilot) E5040 and W5041 messages now include the specific detected key(s) (e.g. `option1`, `option2`, or both) instead of the generic `option1/option2` placeholder. Only one issue is raised even when multiple keys are detected.
30
37
  - (@copilot) Fixed E1111/W1111 checks: E1111 and W1111 are now renamed to E5040 and W5041 (correct numbering range for M5000_Code module). Both checks now correctly exempt adapters where `option1`/`option2` keys are genuinely used in `admin/index.html`, `admin/index_m.html`, or as keys in `admin/jsonConfig.json`/`admin/jsonConfig.json5`. Related to [#746].
@@ -64,6 +64,41 @@ function jobNeedsAll(job, requiredJobs) {
64
64
  return requiredJobs.every(req => needsArr.includes(req));
65
65
  }
66
66
 
67
+ /**
68
+ * Returns true if the job identified by `startJobName` depends on `requiredJobName`
69
+ * either directly or transitively through the needs chain.
70
+ *
71
+ * @param {object} jobs - All jobs in the workflow (map of job name -> job object)
72
+ * @param {string} startJobName - The job to start the search from
73
+ * @param {string} requiredJobName - The job name that must be reachable via needs
74
+ * @returns {boolean} true if requiredJobName is a direct or transitive dependency of startJobName
75
+ */
76
+ function jobDependsOn(jobs, startJobName, requiredJobName) {
77
+ const visited = new Set();
78
+ const queue = [startJobName];
79
+ while (queue.length > 0) {
80
+ const current = queue.shift();
81
+ if (visited.has(current)) {
82
+ continue;
83
+ }
84
+ visited.add(current);
85
+ const job = jobs[current];
86
+ if (!job || !job.needs) {
87
+ continue;
88
+ }
89
+ const needsArr = Array.isArray(job.needs) ? job.needs : [job.needs];
90
+ if (needsArr.includes(requiredJobName)) {
91
+ return true;
92
+ }
93
+ for (const dep of needsArr) {
94
+ if (!visited.has(dep)) {
95
+ queue.push(dep);
96
+ }
97
+ }
98
+ }
99
+ return false;
100
+ }
101
+
67
102
  async function checkTests(context) {
68
103
  console.log('\n[E3000 - E3999] checking tests');
69
104
 
@@ -278,9 +313,10 @@ async function checkTests(context) {
278
313
  } else {
279
314
  context.checks.push('Job "deploy" found.');
280
315
 
281
- // E3016: deploy must need check-and-lint and adapter-tests, but only if those jobs exist in the workflow
316
+ // E3016: deploy must depend (directly or transitively) on check-and-lint and adapter-tests,
317
+ // but only if those jobs exist in the workflow
282
318
  const requiredDependencies = ['check-and-lint', 'adapter-tests'].filter(j => jobs[j]);
283
- if (!jobNeedsAll(jobs['deploy'], requiredDependencies)) {
319
+ if (!requiredDependencies.every(req => jobDependsOn(jobs, 'deploy', req))) {
284
320
  context.errors.push(
285
321
  `[E3016] Workflow "${WORKFLOW_FILE}": job "deploy" must declare "needs" for both "check-and-lint" and "adapter-tests".`,
286
322
  );
package/lib/M5000_Code.js CHANGED
@@ -277,6 +277,7 @@ async function checkCode(context) {
277
277
  if (!context.hasExampleConfigWarning) {
278
278
  const exampleKeys = ['option1', 'option2'];
279
279
  const foundI18nKeys = new Set();
280
+ const foundI18nLangs = new Set();
280
281
  for (const lang of context.cfg.allowedLanguages) {
281
282
  for (const i18nPath of [`/admin/i18n/${lang}/translations.json`, `/admin/i18n/${lang}.json`]) {
282
283
  if (context[i18nPath]) {
@@ -290,6 +291,9 @@ async function checkCode(context) {
290
291
  for (const key of unusedI18nKeys) {
291
292
  foundI18nKeys.add(key);
292
293
  }
294
+ if (unusedI18nKeys.length) {
295
+ foundI18nLangs.add(lang);
296
+ }lang
293
297
  } catch {
294
298
  // parse errors are reported elsewhere
295
299
  }
@@ -298,8 +302,9 @@ async function checkCode(context) {
298
302
  }
299
303
  if (foundI18nKeys.size) {
300
304
  const keyList = [...foundI18nKeys].join(', ');
305
+ const langList = [...foundI18nLangs].join(', ');
301
306
  context.warnings.push(
302
- `[W5041] Example configuration (${keyList}) found in i18n translation files. Please remove example configuration from your code.`,
307
+ `[W5041] Example configuration (${keyList}) found in i18n translation files (${langList}). Please remove example configuration from your code.`,
303
308
  );
304
309
  context.hasExampleConfigWarning = true;
305
310
  }
@@ -1085,6 +1090,6 @@ exports.checkCode = checkCode;
1085
1090
  // [5038] Conflicting JSON files in directory "${dir}": Both ${baseName}.json and ${baseName}.json5 versions of same file exist. Please remove one.
1086
1091
  // [5039] "admin/words.js" found but not referenced anywhere. File seems to be outdated, please consider removing it.
1087
1092
  // [E5040] Example configuration (option1/option2) found in "native" of io-package.json. Please remove example configuration from your code. (moved from E1111 in M1000)
1088
- // [W5041] Example configuration (option1/option2) found in i18n translation files. Please remove example configuration from your code. (renamed from W1111)
1093
+ // [W5041] Example configuration (option1/option2) found in i18n translation files (en, de, ...). Please remove example configuration from your code. (renamed from W1111)
1089
1094
 
1090
1095
  // [5500 - ] see M5500_jsonConfig.js
@@ -13,6 +13,9 @@ const common = require('./common.js');
13
13
 
14
14
  // German language words blacklist - add new words here to extend detection
15
15
  const GERMAN_WORDS = [
16
+ 'der',
17
+ 'die',
18
+ 'das',
16
19
  'Funktion',
17
20
  'Funktionen',
18
21
  'Voraussetzung',
@@ -25,7 +28,17 @@ const GERMAN_WORDS = [
25
28
  'Einstellungen',
26
29
  'Gerät',
27
30
  'Geräte',
31
+ 'Geräte-Konfiguration',
32
+ 'Gerätekonfiguration',
28
33
  'hinzufügen',
34
+ 'nicht',
35
+ 'blockiert',
36
+ 'ist',
37
+ 'von',
38
+ 'bis',
39
+ 'Wertebereich',
40
+ 'vollständig',
41
+ 'Entwickelt mit Unterstützung von',
29
42
  ];
30
43
 
31
44
  // Common English words used to verify if README is written in English
@@ -51,19 +64,23 @@ const ENGLISH_WORDS = [
51
64
  // Minimum number of distinct English words that must be found to consider the text English
52
65
  const ENGLISH_WORD_THRESHOLD = 5;
53
66
 
67
+ // Minimum number of distinct German words that must be detected before raising an error
68
+ const GERMAN_WORD_DETECTION_LIMIT = 3;
69
+
54
70
  /**
55
- * Search for a German word from the blacklist in the given text.
56
- * Returns the first matching word, or null if none found.
71
+ * Search for all German words from the blacklist in the given text.
72
+ * Returns an array of all matching words (in detection order).
57
73
  *
58
74
  * @param {string} text - The text to analyze
59
- * @returns {string|null} The first German word found, or null if none found
75
+ * @returns {string[]} Array of German words found (empty if none)
60
76
  */
61
- function findGermanWord(text) {
77
+ function findAllGermanWords(text) {
78
+ const found = [];
62
79
  for (const word of GERMAN_WORDS) {
63
80
  if (word.includes(' ')) {
64
81
  // For phrases, use case-insensitive substring match
65
82
  if (text.toLowerCase().includes(word.toLowerCase())) {
66
- return word;
83
+ found.push(word);
67
84
  }
68
85
  } else {
69
86
  // Use lookbehind/lookahead for whole-word matching.
@@ -73,11 +90,87 @@ function findGermanWord(text) {
73
90
  const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
74
91
  const regex = new RegExp(`(?<!\\w)${escaped}(?!\\w)`);
75
92
  if (regex.test(text)) {
76
- return word;
93
+ found.push(word);
77
94
  }
78
95
  }
79
96
  }
80
- return null;
97
+ return found;
98
+ }
99
+
100
+ /**
101
+ * Get a short context snippet (up to 3 words) centred on the detected word in the text.
102
+ *
103
+ * @param {string} text - The text to search in
104
+ * @param {string} word - The word to find context for
105
+ * @returns {string} A snippet with one word before and one word after the detected word
106
+ */
107
+ function getWordContext(text, word) {
108
+ let matchIndex;
109
+ let matchLength;
110
+
111
+ if (word.includes(' ')) {
112
+ const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
113
+ const match = new RegExp(escaped, 'i').exec(text);
114
+ if (!match) {
115
+ return word;
116
+ }
117
+ matchIndex = match.index;
118
+ matchLength = match[0].length;
119
+ } else {
120
+ const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
121
+ const match = new RegExp(`(?<!\\w)${escaped}(?!\\w)`).exec(text);
122
+ if (!match) {
123
+ return word;
124
+ }
125
+ matchIndex = match.index;
126
+ matchLength = match[0].length;
127
+ }
128
+
129
+ const before = text.substring(0, matchIndex).trimEnd().split(/\s+/);
130
+ const matchedWord = text.substring(matchIndex, matchIndex + matchLength);
131
+ const after = text
132
+ .substring(matchIndex + matchLength)
133
+ .trimStart()
134
+ .split(/\s+/);
135
+
136
+ const parts = [];
137
+ if (before.length > 0 && before[before.length - 1]) {
138
+ parts.push(before[before.length - 1]);
139
+ }
140
+ parts.push(matchedWord);
141
+ if (after.length > 0 && after[0]) {
142
+ parts.push(after[0]);
143
+ }
144
+
145
+ return parts.join(' ');
146
+ }
147
+
148
+ /**
149
+ * Strip markdown elements that are not visible to the user when the markdown is rendered.
150
+ * This prevents false positives in language detection when German words appear in:
151
+ * - fenced code blocks (``` ... ```)
152
+ * - inline code (`...`)
153
+ * - blockquote lines (lines starting with >)
154
+ * - link URLs [text](url) — the URL part is stripped, the visible text is kept
155
+ * - image markup ![alt](url) — stripped entirely (alt text and URL are both not rendered as prose)
156
+ *
157
+ * @param {string} text - The markdown text to process
158
+ * @returns {string} The text with non-visible parts removed
159
+ */
160
+ function stripMarkdownForLanguageDetection(text) {
161
+ // Remove fenced code blocks (``` ... ```) including those with a language hint (```js ... ```)
162
+ text = text.replace(/```[\s\S]*?```/g, '');
163
+ // Remove inline code (`...`)
164
+ text = text.replace(/`[^`\n]*`/g, '');
165
+ // Remove blockquote lines (lines starting with optional whitespace then >)
166
+ text = text.replace(/^[ \t]*>.*$/gm, '');
167
+ // Remove image markup entirely: ![alt text](url) and ![alt text][ref]
168
+ text = text.replace(/!\[[^\]]*\]\([^)]*\)/g, '');
169
+ text = text.replace(/!\[[^\]]*\]\[[^\]]*\]/g, '');
170
+ // For links [text](url) and [text][ref], keep only the visible link text
171
+ text = text.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1');
172
+ text = text.replace(/\[([^\]]*)\]\[[^\]]*\]/g, '$1');
173
+ return text;
81
174
  }
82
175
 
83
176
  /**
@@ -283,17 +376,21 @@ async function checkReadme(context) {
283
376
  context.checks.push('README.md does not contain an unnecessary Installation section');
284
377
  }
285
378
 
286
- // Check README language
287
- const germanWord = findGermanWord(data);
288
- if (germanWord) {
379
+ // Check README language — strip non-visible markdown elements first so that
380
+ // German words inside code blocks, blockquotes, link URLs or image markup
381
+ // do not trigger false positives.
382
+ const dataForLanguageCheck = stripMarkdownForLanguageDetection(data);
383
+ const germanWords = findAllGermanWords(dataForLanguageCheck);
384
+ if (germanWords.length >= GERMAN_WORD_DETECTION_LIMIT) {
385
+ const snippet = getWordContext(dataForLanguageCheck, germanWords[0]);
289
386
  context.errors.push(
290
- `[E6015] README.md appears to be written in German (detected word: "${germanWord}"). README.md must be written in English. Please translate.`,
387
+ `[E6015] README.md must use English language only but appears to contain German text (detected: "${snippet}"). Please remove or translate.`,
291
388
  );
292
389
  } else {
293
390
  context.checks.push('No German language detected in README.md');
294
- if (!isEnglishText(data)) {
391
+ if (!isEnglishText(dataForLanguageCheck)) {
295
392
  context.warnings.push(
296
- '[W6016] README.md does not appear to be written in English. README.md must be written in English. Please translate.',
393
+ '[W6016] README.md does not appear to be written in English. README.md must be written using English language only. Please translate.',
297
394
  );
298
395
  } else {
299
396
  context.checks.push('README.md appears to be written in English');
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.5.2",
2
+ "version": "5.5.4",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.18.0",