@iobroker/repochecker 4.2.0-alpha.1 → 4.2.0-alpha.2

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
@@ -29,19 +29,24 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
29
29
 
30
30
  <!--
31
31
  Placeholder for the next version (at the beginning of the line):
32
+ ### **WORK IN PROGRESS**
32
33
  -->
33
34
 
34
35
  ## Changelog
36
+ ### 4.2.0-alpha.2 (2025-09-15)
37
+ - (copilot) Added check for deprecated adapter methods (createState/createChannel/createDevice/deleteState/deleteChannel/deleteDevice) (W533) [#182].
38
+ - (copilot) Added check for outdated lib/tools.js file usage (W532) [#432].
39
+
35
40
  ### 4.2.0-alpha.1 (2025-09-14)
36
- - (copilot) Add VS Code schema definitions checker for .vscode/settings.json - validates json.schemas for io-package.json and jsonConfig files [#336].
41
+ - (copilot) Added VS Code schema definitions checker for .vscode/settings.json - validates json.schemas for io-package.json and jsonConfig files [#336].
37
42
  - (copilot) Change W510 to E510: Convert missing admin i18n files from warning to error [#400].
38
43
  - (copilot) Renumbered all issues in M500__JsonConfig.js from 500-511 range to 550-561 range [#481].
39
- - (copilot) Add check for .commitinfo file - error if present (E905), warning if not in .gitignore (W906) [#467].
40
- - (copilot) Add check for allowInit attribute - warn (W204) if true on non-scheduled adapters, suggest (S204) if false on non-scheduled adapters [#181].
41
- - (copilot) Add detection for empty dependency objects in io-package.json (E200, E201) [#422].
42
- - (copilot) Add suggestion to restart 'vis-2' when 'vis' is in restartAdapters (S202) [#412].
43
- - (copilot) Modify W513 gulpfile.js warning to check for @iobroker/adapter-dev dependency and add S531 suggestion [#469].
44
- - (copilot) Fix W195 warning for array elements - add W203 warning for unsupported array encryption [#399].
44
+ - (copilot) Added check for .commitinfo file - error if present (E905), warning if not in .gitignore (W906) [#467].
45
+ - (copilot) Added check for allowInit attribute [#181].
46
+ - (copilot) Added detection for empty dependency objects in io-package.json (E200, E201) [#422].
47
+ - (copilot) Added suggestion to restart 'vis-2' when 'vis' is in restartAdapters (S202) [#412].
48
+ - (copilot) Modified W513 gulpfile.js warning to check for @iobroker/adapter-dev dependency and add S531 suggestion [#469].
49
+ - (copilot) Fixed W195 warning for array elements - add W203 warning for unsupported array encryption [#399].
45
50
 
46
51
  ### 4.1.0 (2025-09-11)
47
52
  - (mcm1957) eslint-config and testing suggestions have been updated.
@@ -377,4 +382,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
377
382
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
378
383
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
379
384
 
385
+
380
386
  THE SOFTWARE.
@@ -9,6 +9,7 @@
9
9
 
10
10
  const axios = require('axios');
11
11
  const compareVersions = require('compare-versions');
12
+ const JSON5 = require('json5');
12
13
 
13
14
  // disable axios caching
14
15
  // axios.defaults.headers = {
@@ -371,7 +372,7 @@ async function checkVSCodeSchemas(context) {
371
372
  // Parse the JSON
372
373
  let settingsJson;
373
374
  try {
374
- settingsJson = JSON.parse(vscodeSettings);
375
+ settingsJson = JSON5.parse(vscodeSettings);
375
376
  } catch {
376
377
  context.errors.push('[E437] .vscode/settings.json file contains invalid JSON.');
377
378
  return;
package/lib/M500_Code.js CHANGED
@@ -100,6 +100,38 @@ async function checkCode(context) {
100
100
  readFiles.push(`/${context.packageJson.main}`);
101
101
  }
102
102
 
103
+ // Add all executable files to readFiles for proper lib/tools.js usage scanning
104
+ // We need to discover files first to know which ones to read
105
+ let tempFilesList = [];
106
+ if (common.isLocal()) {
107
+ // For local mode, scan the directory to find all files first
108
+ tempFilesList = getAllFiles(process.cwd(), '', []);
109
+ } else {
110
+ // For remote mode, we'll need to get the files list first
111
+ tempFilesList = await common.getFilesList(context);
112
+ }
113
+
114
+ // Add all executable files (.js, .mjs, .cjs, .ts) to readFiles, excluding certain directories
115
+ const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
116
+ const excludeDirsForExecutables = ['node_modules', 'admin', 'admin-src', '.git', '.vscode', '.dev-server'];
117
+
118
+ tempFilesList.forEach(filePath => {
119
+ // Skip files in excluded directories
120
+ const pathParts = filePath.split('/').filter(part => part !== '');
121
+ const isInExcludedDir = pathParts.some(part => excludeDirsForExecutables.includes(part));
122
+
123
+ if (!isInExcludedDir) {
124
+ const ext = path.extname(filePath);
125
+ if (executableExtensions.includes(ext)) {
126
+ // Ensure the file path starts with /
127
+ const normalizedPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
128
+ if (!readFiles.includes(normalizedPath)) {
129
+ readFiles.push(normalizedPath);
130
+ }
131
+ }
132
+ }
133
+ });
134
+
103
135
  // if (!context.ioPackageJson.common.noConfig) {
104
136
  // if (context.ioPackageJson.common.materialize || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize')) {
105
137
  // readFiles.push('admin/index_m.html');
@@ -491,7 +523,105 @@ async function checkCode(context) {
491
523
  }
492
524
  }
493
525
 
494
- // first free 0530
526
+ // Check for outdated lib/tools.js
527
+ if (context.filesList.includes('/lib/tools.js')) {
528
+ // Check if lib/tools.js is used anywhere in the repository
529
+ let isUsed = false;
530
+
531
+ // Search through all loaded files for references to tools.js
532
+ for (const fileName of Object.keys(context)) {
533
+ if (fileName.startsWith('/') && typeof context[fileName] === 'string') {
534
+ const content = context[fileName];
535
+ // Look for various patterns that might reference lib/tools.js
536
+ if (
537
+ content.includes('lib/tools') ||
538
+ content.includes('./lib/tools') ||
539
+ content.includes('../lib/tools')
540
+ ) {
541
+ isUsed = true;
542
+ break;
543
+ }
544
+ }
545
+ }
546
+
547
+ if (!isUsed) {
548
+ context.warnings.push(
549
+ '[S532] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.',
550
+ );
551
+ }
552
+ }
553
+
554
+ // Check for deprecated adapter methods (createState, createChannel, createDevice, deleteState, deleteChannel, deleteDevice)
555
+ const deprecatedMethods = [
556
+ 'createState',
557
+ 'createChannel',
558
+ 'createDevice',
559
+ 'deleteState',
560
+ 'deleteChannel',
561
+ 'deleteDevice',
562
+ ];
563
+
564
+ // Track which deprecated methods have already been reported
565
+ const reportedMethods = new Set();
566
+
567
+ // Search through all loaded executable files for deprecated method usage
568
+ for (const fileName of Object.keys(context)) {
569
+ if (fileName.startsWith('/') && typeof context[fileName] === 'string') {
570
+ // Skip files in excluded directories (admin, tests, etc.)
571
+ const pathParts = fileName.split('/').filter(part => part !== '');
572
+ const isInExcludedDir = pathParts.some(part => excludeDirsForExecutables.includes(part));
573
+
574
+ if (isInExcludedDir) {
575
+ continue;
576
+ }
577
+
578
+ // Only check executable files
579
+ const ext = path.extname(fileName);
580
+ const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
581
+ if (!executableExtensions.includes(ext)) {
582
+ continue;
583
+ }
584
+
585
+ const content = context[fileName];
586
+ const lines = content.split(/\r\n|\r|\n/g);
587
+
588
+ for (let i = 0; i < lines.length; i++) {
589
+ const line = lines[i];
590
+
591
+ for (const method of deprecatedMethods) {
592
+ // Skip if this method has already been reported
593
+ if (reportedMethods.has(method)) {
594
+ continue;
595
+ }
596
+
597
+ // Check for this.methodName or adapter.methodName patterns
598
+ const patterns = [
599
+ new RegExp(`\\bthis\\.${method}\\s*\\(`, 'g'),
600
+ new RegExp(`\\badapter\\.${method}\\s*\\(`, 'g'),
601
+ ];
602
+
603
+ for (const pattern of patterns) {
604
+ if (pattern.test(line)) {
605
+ // Make sure this is not a private function definition
606
+ const functionDefPattern = new RegExp(
607
+ `(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
608
+ 'i',
609
+ );
610
+ if (!functionDefPattern.test(line)) {
611
+ context.warnings.push(
612
+ `[W533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
613
+ );
614
+ reportedMethods.add(method);
615
+ }
616
+ break; // Only warn once per line
617
+ }
618
+ }
619
+ }
620
+ }
621
+ }
622
+ }
623
+
624
+ // first free 0534
495
625
  // 550 - xxx reserved for jsonConfig module
496
626
 
497
627
  return context;
@@ -540,5 +670,7 @@ exports.checkCode = checkCode;
540
670
  // [529] Plugin "manual-review" missing at .releaseconfig.json. Please add.
541
671
  // [530] .releaseconfig.json is no valid json file - ${e}.
542
672
  // [531] "gulpfile.js" found in repo with @iobroker/adapter-dev. Check if gulp is still needed.
673
+ // [532] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.
674
+ // [533] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.
543
675
 
544
676
  // [550 - ] see M500_jsonConfig.js
@@ -16,7 +16,10 @@ const issuesToWatchAsError = [
16
16
  'Compatibility check and testing for Responsive Design (materialize)',
17
17
  ];
18
18
 
19
- const issuesToWatchAsWarning = ['Migration to ESLint 9 and @iobroker/eslint-config'];
19
+ const issuesToWatchAsWarning = [
20
+ 'Migration to ESLint 9 and @iobroker/eslint-config',
21
+ 'Translations update from ioBroker Translation System',
22
+ ];
20
23
 
21
24
  // disable axios caching
22
25
  axios.defaults.headers.common = {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.0-alpha.1",
2
+ "version": "4.2.0-alpha.2",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.11.0",