feat(aa): ensure comments are neither merged nor sorted.

This commit is contained in:
Alexandre Pujol 2024-06-20 22:29:22 +01:00
parent 58c07e5ea5
commit d6424cb950
Failed to generate hash of commit
2 changed files with 5 additions and 6 deletions

View file

@ -34,7 +34,7 @@ func (r *Comment) Validate() error {
}
func (r *Comment) Compare(other Rule) int {
return 0
return 0 // Comments are always equal to each other as they are not compared
}
func (r *Comment) String() string {

View file

@ -157,20 +157,19 @@ func (r Rules) Merge() Rules {
continue
}
kindOfI := r[i].Kind()
kindOfJ := r[j].Kind()
if kindOfI != kindOfJ {
if kindOfI != r[j].Kind() {
continue
}
// If rules are identical, merge them
if r[i].Compare(r[j]) == 0 {
// If rules are identical, merge them. Ignore comments
if kindOfI != COMMENT && r[i].Compare(r[j]) == 0 {
r = r.Delete(j)
j--
continue
}
// File rule
if kindOfI == FILE && kindOfJ == FILE {
if kindOfI == FILE {
// Merge access
fileI := r[i].(*File)
fileJ := r[j].(*File)