Skip to content

Commit

Permalink
Removed tests and rules about sketch.json (now deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Oct 16, 2024
1 parent 07ead9b commit e736753
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 81 deletions.
34 changes: 0 additions & 34 deletions internal/rule/ruleconfiguration/ruleconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,40 +1504,6 @@ var configurations = []Type{
ErrorModes: []rulemode.Type{rulemode.Strict},
RuleFunction: rulefunction.MissingLicenseFile,
},
{
ProjectType: projecttype.Sketch,
SuperprojectType: projecttype.All,
Category: "sketch.json",
Subcategory: "general",
ID: "SM001",
Brief: "sketch.json JSON format",
Description: "The sketch's `sketch.json` metadata file is not a valid JSON document.",
MessageTemplate: "sketch.json is not a valid JSON document.",
Reference: "",
DisableModes: nil,
EnableModes: []rulemode.Type{rulemode.Default},
InfoModes: nil,
WarningModes: []rulemode.Type{rulemode.Permissive},
ErrorModes: []rulemode.Type{rulemode.Default},
RuleFunction: rulefunction.SketchDotJSONJSONFormat,
},
{
ProjectType: projecttype.Sketch,
SuperprojectType: projecttype.All,
Category: "sketch.json",
Subcategory: "general",
ID: "SM002",
Brief: "sketch.json data format",
Description: "The sketch's `sketch.json` metadata file does not have a valid data format.",
MessageTemplate: "sketch.json has an invalid data format: {{.}}",
Reference: "https://arduino.github.io/arduino-cli/latest/sketch-specification/#metadata",
DisableModes: nil,
EnableModes: []rulemode.Type{rulemode.Default},
InfoModes: nil,
WarningModes: []rulemode.Type{rulemode.Permissive},
ErrorModes: []rulemode.Type{rulemode.Default},
RuleFunction: rulefunction.SketchDotJSONFormat,
},
{
ProjectType: projecttype.Platform,
SuperprojectType: projecttype.Platform,
Expand Down
2 changes: 1 addition & 1 deletion internal/rule/ruleconfiguration/ruleconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestConfigurationResolution(t *testing.T) {
for _, ruleConfiguration := range ruleconfiguration.Configurations() {
for ruleMode := range rulemode.Types {
enabled, err := rule.IsEnabled(ruleConfiguration, map[rulemode.Type]bool{ruleMode: true})
assert.Nil(t, err, fmt.Sprintf("Enable configuration of rule %s doesn't resolve for rule mode %s", ruleConfiguration.ID, ruleMode))
assert.NoError(t, err, fmt.Sprintf("Enable configuration of rule %s doesn't resolve for rule mode %s", ruleConfiguration.ID, ruleMode))
if err == nil && enabled {
_, err := rulelevel.FailRuleLevel(ruleConfiguration, map[rulemode.Type]bool{ruleMode: true})
assert.Nil(t, err, fmt.Sprintf("Level configuration of rule %s doesn't resolve for rule mode %s", ruleConfiguration.ID, ruleMode))
Expand Down
28 changes: 0 additions & 28 deletions internal/rule/rulefunction/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,3 @@ func IncorrectSketchSrcFolderNameCase() (result ruleresult.Type, output string)

return ruleresult.Pass, ""
}

// SketchDotJSONJSONFormat checks whether the sketch.json metadata file is a valid JSON document.
func SketchDotJSONJSONFormat() (result ruleresult.Type, output string) {
metadataPath := sketch.MetadataPath(projectdata.ProjectPath())
if metadataPath == nil {
return ruleresult.Skip, "No metadata file"
}

if isValidJSON(metadataPath) {
return ruleresult.Pass, ""
}

return ruleresult.Fail, ""
}

// SketchDotJSONFormat checks whether the sketch.json metadata file has the required data format.
func SketchDotJSONFormat() (result ruleresult.Type, output string) {
metadataPath := sketch.MetadataPath(projectdata.ProjectPath())
if metadataPath == nil {
return ruleresult.Skip, "No metadata file"
}

if projectdata.MetadataLoadError() == nil {
return ruleresult.Pass, ""
}

return ruleresult.Fail, projectdata.MetadataLoadError().Error()
}
18 changes: 0 additions & 18 deletions internal/rule/rulefunction/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,3 @@ func TestIncorrectSketchSrcFolderNameCase(t *testing.T) {

checkSketchRuleFunction(IncorrectSketchSrcFolderNameCase, testTables, t)
}

func TestSketchDotJSONJSONFormat(t *testing.T) {
testTables := []sketchRuleFunctionTestTable{
{"No metadata file", "NoMetadataFile", ruleresult.Skip, ""},
{"Valid", "ValidMetadataFile", ruleresult.Pass, ""},
}

checkSketchRuleFunction(SketchDotJSONJSONFormat, testTables, t)
}

func TestSketchDotJSONFormat(t *testing.T) {
testTables := []sketchRuleFunctionTestTable{
{"No metadata file", "NoMetadataFile", ruleresult.Skip, ""},
{"Valid", "ValidMetadataFile", ruleresult.Pass, ""},
}

checkSketchRuleFunction(SketchDotJSONFormat, testTables, t)
}

0 comments on commit e736753

Please sign in to comment.