From 10879f3bad08d2d5d14d445942b2b65bf85bc0f2 Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Wed, 4 Feb 2026 17:07:21 +0300 Subject: [PATCH 1/3] add rule Signed-off-by: Sinelnikov Michail --- pkg/linters/module/rules/module_yaml.go | 4 +++ pkg/linters/module/rules/module_yaml_test.go | 29 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pkg/linters/module/rules/module_yaml.go b/pkg/linters/module/rules/module_yaml.go index 161cf2fb..777c3fdf 100644 --- a/pkg/linters/module/rules/module_yaml.go +++ b/pkg/linters/module/rules/module_yaml.go @@ -282,6 +282,10 @@ func (r *DefinitionFileRule) CheckDefinitionFile(modulePath string, errorList *e if yml.Critical && yml.Weight == 0 { errorList.Error("Field 'weight' must not be zero for critical modules") } + + if !yml.Critical && yml.Weight > 0 { + errorList.Warn("Field 'weight' is ignored for non-critical modules") + } } func (m ModuleRequirements) validateRequirements(errorList *errors.LintRuleErrorsList) { diff --git a/pkg/linters/module/rules/module_yaml_test.go b/pkg/linters/module/rules/module_yaml_test.go index 0770d56f..543d1a2b 100644 --- a/pkg/linters/module/rules/module_yaml_test.go +++ b/pkg/linters/module/rules/module_yaml_test.go @@ -254,6 +254,35 @@ descriptions: assert.Contains(t, errorList.GetErrors()[0].Text, "Field 'weight' must not be zero for critical modules") } +func TestCheckDefinitionFile_NonCriticalModuleWithWeight(t *testing.T) { + tempDir := t.TempDir() + moduleFilePath := filepath.Join(tempDir, ModuleConfigFilename) + + err := os.WriteFile(moduleFilePath, []byte(` +name: test-non-critical +weight: 10 +stage: Experimental +descriptions: + en: "Test description" +`), 0600) + require.NoError(t, err) + + rule := NewDefinitionFileRule(false) + errorList := errors.NewLintRuleErrorsList() + rule.CheckDefinitionFile(tempDir, errorList) + + assert.False(t, errorList.ContainsErrors(), "Expected no errors for non-critical module with weight") + + found := false + for _, e := range errorList.GetErrors() { + if e.Level == pkg.Warn && e.Text == "Field 'weight' is ignored for non-critical modules" { + found = true + break + } + } + assert.True(t, found, "Expected warning for non-critical module with weight") +} + func TestCheckDefinitionFile_InvalidStage(t *testing.T) { tempDir := t.TempDir() moduleFilePath := filepath.Join(tempDir, ModuleConfigFilename) From ca0cf2fdce91a0871cad4c4b48e00ebad67ea8c5 Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Mon, 9 Feb 2026 11:02:17 +0300 Subject: [PATCH 2/3] update error Signed-off-by: Sinelnikov Michail --- pkg/linters/module/rules/module_yaml.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/linters/module/rules/module_yaml.go b/pkg/linters/module/rules/module_yaml.go index 777c3fdf..b0419832 100644 --- a/pkg/linters/module/rules/module_yaml.go +++ b/pkg/linters/module/rules/module_yaml.go @@ -284,7 +284,7 @@ func (r *DefinitionFileRule) CheckDefinitionFile(modulePath string, errorList *e } if !yml.Critical && yml.Weight > 0 { - errorList.Warn("Field 'weight' is ignored for non-critical modules") + errorList.Warn("Unnecessary field 'weight' must be removed for non-critical module") } } From e54b04c4f2f324a484772040ce7e8e784f2636f5 Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Mon, 9 Feb 2026 12:13:35 +0300 Subject: [PATCH 3/3] fix tests Signed-off-by: Sinelnikov Michail --- pkg/linters/module/rules/module_yaml_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/linters/module/rules/module_yaml_test.go b/pkg/linters/module/rules/module_yaml_test.go index 543d1a2b..3d82b8a1 100644 --- a/pkg/linters/module/rules/module_yaml_test.go +++ b/pkg/linters/module/rules/module_yaml_test.go @@ -275,7 +275,7 @@ descriptions: found := false for _, e := range errorList.GetErrors() { - if e.Level == pkg.Warn && e.Text == "Field 'weight' is ignored for non-critical modules" { + if e.Level == pkg.Warn && e.Text == "Unnecessary field 'weight' must be removed for non-critical module" { found = true break }