Skip to content

Fix: careful with linenumber removal in order to improve code coverage#281

Draft
lkdvos wants to merge 1 commit into
masterfrom
ld-codecov
Draft

Fix: careful with linenumber removal in order to improve code coverage#281
lkdvos wants to merge 1 commit into
masterfrom
ld-codecov

Conversation

@lkdvos

@lkdvos lkdvos commented Jun 15, 2026

Copy link
Copy Markdown
Member

This is a claude-aided attempt of resolving #280.
From what I could tell, the removal of the line numbers is what causes the codecov gaps.

@Jutho I'm not entirely sure if we really need these to begin with, or if this is just a cosmetic thing to make the generated expressions easier to inspect?

In any case, I still have to more carefully investigate if this actually resolves the issue, and additionally if this automatically carries over to @planar and @plansor.

@github-actions

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/indexnotation/postprocessors.jl b/src/indexnotation/postprocessors.jl
index 21bc613..8909dd5 100644
--- a/src/indexnotation/postprocessors.jl
+++ b/src/indexnotation/postprocessors.jl
@@ -48,8 +48,10 @@ coverage).
 function removeinternallinenumbernodes(ex)
     if isexpr(ex, :block)
         # within a block, `LineNumberNode`s are statement markers: drop the internal ones
-        args = Any[removeinternallinenumbernodes(e) for e in ex.args
-            if !_isinternallinenumber(e)]
+        args = Any[
+            removeinternallinenumbernodes(e) for e in ex.args
+                if !_isinternallinenumber(e)
+        ]
         return Expr(:block, args...)
     elseif isa(ex, Expr)
         # elsewhere (e.g. the mandatory 2nd argument of a `:macrocall`) a `LineNumberNode` may
diff --git a/test/butensor.jl b/test/butensor.jl
index b0e4d50..ebb837c 100644
--- a/test/butensor.jl
+++ b/test/butensor.jl
@@ -13,10 +13,12 @@ using Bumper
     lnns = LineNumberNode[]
     collect_lnns(x) = x isa LineNumberNode ? push!(lnns, x) :
         x isa Expr && foreach(collect_lnns, x.args)
-    collect_lnns(@macroexpand @butensor begin
-        T[a, b] := X[a, c] * Y[c, b]
-        Z[a, b] := T[a, c] * W[c, b]
-    end)
+    collect_lnns(
+        @macroexpand @butensor begin
+            T[a, b] := X[a, c] * Y[c, b]
+            Z[a, b] := T[a, c] * W[c, b]
+        end
+    )
     @test !any(l -> startswith(String(l.file), pkgsrc), lnns)
     @test count(l -> String(l.file) == @__FILE__, lnns) >= 2
 end
diff --git a/test/macro_kwargs.jl b/test/macro_kwargs.jl
index 621bc05..b83d687 100644
--- a/test/macro_kwargs.jl
+++ b/test/macro_kwargs.jl
@@ -97,8 +97,10 @@ end
 # parser's own internal ones (which would otherwise pollute the package's coverage).
 @testset "line numbers (issue #280)" begin
     collectlinenumbernodes(ex, acc = LineNumberNode[]) =
-        (ex isa LineNumberNode ? push!(acc, ex) :
-         ex isa Expr && foreach(e -> collectlinenumbernodes(e, acc), ex.args); acc)
+        (
+        ex isa LineNumberNode ? push!(acc, ex) :
+            ex isa Expr && foreach(e -> collectlinenumbernodes(e, acc), ex.args); acc
+    )
     pkgsrc = dirname(pathof(TensorOperations))
     pkglnns(lnns) = filter(l -> startswith(String(l.file), pkgsrc), lnns)
     userlines(lnns) = sort!(unique!([l.line for l in lnns if String(l.file) == @__FILE__]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant