Skip to content

Commit cb40e8f

Browse files
committed
Fix test compilation errors
- Make CATEGORY_* constants public in fluff_rules - Fix fix_suggestion_t structure usage in test_diagnostics.f90 - Add missing count() and has_errors() methods to diagnostic_collection_t - Rename count() to get_count() to avoid name conflict with field - Fix string_array_t type usage in test_intelligent_caching.f90 All tests now compile successfully. Some linking errors remain due to missing LSP implementations, but compilation phase is fixed.
1 parent 5017fdc commit cb40e8f

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

src/fluff_diagnostics/fluff_diagnostics.f90

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ module fluff_diagnostics
8484
procedure :: to_json => collection_to_json
8585
procedure :: to_sarif => collection_to_sarif
8686
procedure :: get_stats => collection_get_stats
87+
procedure :: get_count => collection_count
88+
procedure :: has_errors => collection_has_errors
8789
end type diagnostic_collection_t
8890

8991
! Public procedures
@@ -736,6 +738,28 @@ function collection_get_stats(this) result(stats)
736738
stats = this%stats
737739
end function collection_get_stats
738740

741+
! Get count of diagnostics in collection
742+
function collection_count(this) result(count)
743+
class(diagnostic_collection_t), intent(in) :: this
744+
integer :: count
745+
count = this%count
746+
end function collection_count
747+
748+
! Check if collection has error-level diagnostics
749+
function collection_has_errors(this) result(has_errors)
750+
class(diagnostic_collection_t), intent(in) :: this
751+
logical :: has_errors
752+
integer :: i
753+
754+
has_errors = .false.
755+
do i = 1, this%count
756+
if (this%diagnostics(i)%severity == SEVERITY_ERROR) then
757+
has_errors = .true.
758+
return
759+
end if
760+
end do
761+
end function collection_has_errors
762+
739763
! Helper functions for string conversion
740764
function int_to_string(val) result(str)
741765
integer, intent(in) :: val

src/fluff_rules/fluff_rules.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ module fluff_rules
2020
public :: get_performance_rules
2121
public :: get_correctness_rules
2222

23+
! Public constants
24+
public :: CATEGORY_STYLE, CATEGORY_PERFORMANCE, CATEGORY_CORRECTNESS
25+
2326
contains
2427

2528
! Get all built-in rules

test/test_diagnostics.f90

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ subroutine test_diagnostic_collection(error)
9999
call collection%add(diag1)
100100
call collection%add(diag2)
101101

102-
call check(error, collection%count() == 2, "Collection should have 2 diagnostics")
102+
call check(error, collection%get_count() == 2, "Collection should have 2 diagnostics")
103103
if (allocated(error)) return
104104

105105
call check(error, collection%has_errors(), "Collection should have errors")
@@ -109,22 +109,29 @@ end subroutine test_diagnostic_collection
109109
subroutine test_fix_suggestion(error)
110110
type(error_type), allocatable, intent(out) :: error
111111
type(fix_suggestion_t) :: fix
112+
type(text_edit_t) :: edit
112113
type(source_range_t) :: loc
113114

114115
loc%start%line = 5
115116
loc%start%column = 1
116117
loc%end%line = 5
117118
loc%end%column = 20
118119

120+
! Create text edit
121+
edit%range = loc
122+
edit%new_text = "implicit none"
123+
124+
! Create fix with proper structure
119125
fix%description = "Add implicit none"
120-
fix%location = loc
121-
fix%replacement = "implicit none"
126+
allocate(fix%edits(1))
127+
fix%edits(1) = edit
128+
fix%is_safe = .true.
122129

123130
call check(error, fix%description == "Add implicit none", &
124131
"Fix description should match")
125132
if (allocated(error)) return
126133

127-
call check(error, fix%replacement == "implicit none", &
134+
call check(error, fix%edits(1)%new_text == "implicit none", &
128135
"Fix replacement should match")
129136

130137
end subroutine test_fix_suggestion

test/test_intelligent_caching.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,14 @@ end function test_dependency_invalidation
652652
function test_cross_file_dependencies() result(success)
653653
logical :: success
654654
type(analysis_cache_t) :: cache
655-
character(len=:), allocatable :: affected_files(:)
655+
type(string_array_t) :: affected_files
656656

657657
cache = create_analysis_cache()
658658
call cache%add_dependency("file1.f90", "common.f90")
659659
call cache%add_dependency("file2.f90", "common.f90")
660660

661661
affected_files = cache%get_files_depending_on("common.f90")
662-
success = size(affected_files) == 2
662+
success = affected_files%count == 2
663663

664664
end function test_cross_file_dependencies
665665

0 commit comments

Comments
 (0)