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 { 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 { func (r *Comment) String() string {

View file

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