From ce5f4a2c51ec29feb466fbe99960b52bc4cb61d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Fri, 2 Aug 2024 10:54:04 +0200 Subject: [PATCH 1/3] Manage missing required attribute error --- src/parser/TerraformListener.js | 23 +++++++++++++---------- tests/resources/js/parserError.js | 12 ++++++++++++ tests/resources/tf/parserError.tf | 2 ++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/parser/TerraformListener.js b/src/parser/TerraformListener.js index bcc2df1..d21e73b 100644 --- a/src/parser/TerraformListener.js +++ b/src/parser/TerraformListener.js @@ -40,6 +40,11 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { }); } + checkMissingAttributes(ctx) { + this.currentComponent.validateRequiredAttributes() + .forEach((error) => this.addError(ctx, error)); + } + addComponent() { this.currentComponent.path = this.currentFile.path; this.pluginData.components.push(this.currentComponent); @@ -120,7 +125,8 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { } // Exit a parse tree produced by terraformParser#resource. - exitResource() { + exitResource(ctx) { + this.checkMissingAttributes(ctx); this.addComponent(); } @@ -131,7 +137,8 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { } // Exit a parse tree produced by terraformParser#data. - exitData() { + exitData(ctx) { + this.checkMissingAttributes(ctx); this.addComponent(); } @@ -142,7 +149,8 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { } // Exit a parse tree produced by terraformParser#provider. - exitProvider() { + exitProvider(ctx) { + this.checkMissingAttributes(ctx); this.addComponent(); } @@ -179,7 +187,8 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { } // Exit a parse tree produced by terraformParser#module. - exitModule() { + exitModule(ctx) { + this.checkMissingAttributes(ctx); this.addComponent(); } @@ -552,12 +561,6 @@ class TerraformListener extends antlr4.tree.ParseTreeListener { this.currentField.type = type; } - this.currentField.validateDefinitionType(); - this.currentField.validateType(); - this.currentField.validateRequired(); - this.currentField.validateRuleMinMax(); - this.currentField.validateRuleValues(); - this.currentField.validateRuleRegex(); this.currentField.getErrors() .forEach((error) => this.addError(ctx, error)); } diff --git a/tests/resources/js/parserError.js b/tests/resources/js/parserError.js index 7d4f22d..ca8a91e 100644 --- a/tests/resources/js/parserError.js +++ b/tests/resources/js/parserError.js @@ -75,6 +75,18 @@ const errors = [ severity: ParserLog.SEVERITY_ERROR, initialErrorMessage: null, }), + new ParserLog({ + path: 'parserError.tf', + componentId: 'id_5', + attribute: 'region', + startLineNumber: 15, + startColumn: 1, + endLineNumber: 15, + endColumn: 32, + message: 'parser.error.required', + severity: ParserLog.SEVERITY_ERROR, + initialErrorMessage: null, + }), ]; export default errors; diff --git a/tests/resources/tf/parserError.tf b/tests/resources/tf/parserError.tf index 7032e3e..c4840a1 100644 --- a/tests/resources/tf/parserError.tf +++ b/tests/resources/tf/parserError.tf @@ -11,3 +11,5 @@ resource "unknown" "test3" {} resource "aws_lb_target_group" "" {} blabla "test" {} + +provider "aws" {} From 5fcbd0d3a117ed92f51e71666986836625af8327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Fri, 2 Aug 2024 11:03:03 +0200 Subject: [PATCH 2/3] Update plugin-core version to 0.26.2 --- package-lock.json | 58 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2939428..710e257 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Mozilla Public License 2.0", "dependencies": { "antlr4": "=4.13.1", - "leto-modelizer-plugin-core": "github:ditrit/leto-modelizer-plugin-core#0.26.1", + "leto-modelizer-plugin-core": "github:ditrit/leto-modelizer-plugin-core#0.26.2", "nunjucks": "=3.2.4" }, "devDependencies": { @@ -2858,9 +2858,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", - "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", + "version": "22.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", + "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", "dev": true, "dependencies": { "undici-types": "~6.11.1" @@ -3988,9 +3988,9 @@ } }, "node_modules/browserslist": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", - "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", + "integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", "dev": true, "funding": [ { @@ -4007,9 +4007,9 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001640", - "electron-to-chromium": "^1.4.820", - "node-releases": "^2.0.14", + "caniuse-lite": "^1.0.30001646", + "electron-to-chromium": "^1.5.4", + "node-releases": "^2.0.18", "update-browserslist-db": "^1.1.0" }, "bin": { @@ -4185,9 +4185,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001645", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001645.tgz", - "integrity": "sha512-GFtY2+qt91kzyMk6j48dJcwJVq5uTkk71XxE3RtScx7XWRLsO7bU44LOFkOZYR8w9YMS0UhPSYpN/6rAMImmLw==", + "version": "1.0.30001646", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001646.tgz", + "integrity": "sha512-dRg00gudiBDDTmUhClSdv3hqRfpbOnU28IpI1T6PBTLWa+kOj0681C8uML3PifYfREuBrVjDGhL3adYpBT6spw==", "dev": true, "funding": [ { @@ -9079,8 +9079,8 @@ } }, "node_modules/leto-modelizer-plugin-core": { - "version": "0.26.1", - "resolved": "git+ssh://git@github.com/ditrit/leto-modelizer-plugin-core.git#4f4e7b838aa401bfc013f6fc116d13c2c02d957f", + "version": "0.26.2", + "resolved": "git+ssh://git@github.com/ditrit/leto-modelizer-plugin-core.git#b7d92635bdbcc3aa072ce5369249022a06986726", "license": "Mozilla Public License Version 2.0", "dependencies": { "d3": "=7.9.0", @@ -14372,9 +14372,9 @@ "dev": true }, "@types/node": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", - "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", + "version": "22.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", + "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", "dev": true, "requires": { "undici-types": "~6.11.1" @@ -15248,14 +15248,14 @@ } }, "browserslist": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", - "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", + "integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001640", - "electron-to-chromium": "^1.4.820", - "node-releases": "^2.0.14", + "caniuse-lite": "^1.0.30001646", + "electron-to-chromium": "^1.5.4", + "node-releases": "^2.0.18", "update-browserslist-db": "^1.1.0" } }, @@ -15382,9 +15382,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001645", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001645.tgz", - "integrity": "sha512-GFtY2+qt91kzyMk6j48dJcwJVq5uTkk71XxE3RtScx7XWRLsO7bU44LOFkOZYR8w9YMS0UhPSYpN/6rAMImmLw==", + "version": "1.0.30001646", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001646.tgz", + "integrity": "sha512-dRg00gudiBDDTmUhClSdv3hqRfpbOnU28IpI1T6PBTLWa+kOj0681C8uML3PifYfREuBrVjDGhL3adYpBT6spw==", "dev": true }, "catharsis": { @@ -18961,8 +18961,8 @@ "dev": true }, "leto-modelizer-plugin-core": { - "version": "git+ssh://git@github.com/ditrit/leto-modelizer-plugin-core.git#4f4e7b838aa401bfc013f6fc116d13c2c02d957f", - "from": "leto-modelizer-plugin-core@github:ditrit/leto-modelizer-plugin-core#0.26.1", + "version": "git+ssh://git@github.com/ditrit/leto-modelizer-plugin-core.git#b7d92635bdbcc3aa072ce5369249022a06986726", + "from": "leto-modelizer-plugin-core@github:ditrit/leto-modelizer-plugin-core#0.26.2", "requires": { "d3": "=7.9.0", "d3-hierarchy": "=3.1.2", diff --git a/package.json b/package.json index 08bdd21..3cd211c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "homepage": "https://github.com/ditrit/terrator-plugin#readme", "dependencies": { "antlr4": "=4.13.1", - "leto-modelizer-plugin-core": "github:ditrit/leto-modelizer-plugin-core#0.26.1", + "leto-modelizer-plugin-core": "github:ditrit/leto-modelizer-plugin-core#0.26.2", "nunjucks": "=3.2.4" }, "devDependencies": { From 7453d145666c6383b3ae387797d63411a8cc69d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Moitti=C3=A9?= Date: Fri, 2 Aug 2024 11:03:12 +0200 Subject: [PATCH 3/3] Update changelog --- changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 5d88874..0424884 100644 --- a/changelog.md +++ b/changelog.md @@ -12,11 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Default attributes for metadata. - Error management. - I18n management. -- Unknown definition attribute. +- New attribute for Unknown component definition. ### Changed -- Update plugin-core to version 0.26.0. +- Update plugin-core to version 0.26.2. ## [0.10.0] - 2024/07/11