Skip to content

feat: add Elixir, F# and ObjC to health complexity maps - #2152

Merged
RaghavChamadiya merged 1 commit into
repowise-dev:mainfrom
krishna231122-del:language-clean
Sep 11, 2026
Merged

RaghavChamadiya merged 1 commit into
repowise-dev:mainfrom
krishna231122-del:language-clean

Conversation

@krishna231122-del

Copy link
Copy Markdown
Contributor

Summary

  • Enables code health coverage (complexity, dataflow, nesting) for Elixir, F#, and Objective-C.
  • Adds LanguageNodeMap definitions in languages.py for the new parser capabilities.
  • Safely configures Elixir to prevent macro misclassification, while properly handling Objective-C's message syntax and F#'s type definitions.

Related Issues

  • Completes recent ingestion updates for Elixir, F#, and Objective-C

Test Plan

  • Tests pass (pytest)
  • Lint passes (ruff check .)
  • Web build passes (npm run build) (if frontend changes)

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks @krishna231122-del, and the instinct is right: these three shipped as parsed languages on 5 September and got no complexity signal at all, so the gap is real and this is the file that closes it.

I test-merged this onto current main and ran the real walker against small samples of each language, because a node map is one of the few things where reading it cannot tell you whether it is right. Two of the three need another pass, and the third is close.

Elixir does not work, and I do not think it can with this shape. In tree-sitter-elixir there is no def node: defmodule, def, defp and an ordinary function call are all call nodes, distinguished only by the identifier text of the target. So function_kinds={"call"} matches the module too, and since the walker takes the outermost match, every Elixir file collapses to one function named after the keyword:

defmodule A do
  def one(x), do: x
end

defmodule B do
  def two(x), do: x
end
elixir functions: 2
   name='defmodule' ccn=1 nloc=3
   name='defmodule' ccn=1 nloc=3

Both real functions are invisible, the name in the report is a keyword, and with branch_kinds empty the if in a body adds nothing, so every Elixir file scores ccn 1 forever. That is not the "no signal" degrade the module docstring promises at the top of languages.py, it is a confident wrong answer, and health scores read from it. Since LanguageNodeMap has no way to say "a call whose target identifier is def or defp", I would drop _ELIXIR from this PR entirely. No entry means no rows, which is the honest state until the map or the walker grows a text predicate for function kinds. Worth its own issue if you want to take that on.

Objective-C is nearly there, two fixes. function_kinds contains "declaration", and in this grammar a declaration is any variable declaration, so file-scope globals become functions:

static int gCounter = 0;
static NSString *gName = nil;
int helper(int x);

@implementation Ledger
- (int)post:(int)amount { if (amount > 0) { return 1; } return 0; }
@end
objc functions: 4
   name='post' ccn=2 nloc=4
   name='helper' ccn=1 nloc=1
   name='gName' ccn=1 nloc=1
   name='gCounter' ccn=1 nloc=1

Two globals counted as functions of complexity 1 each, which drags the file's average complexity down toward 1 on exactly the headers-and-globals files where it matters. Your own C map from #2113 already gets this right: function_kinds={"function_definition"} with declaration only in local_decl_kinds. Copy that.

Second, catch_kinds is empty while the grammar does emit catch_clause. Per the docstring at the top of the file, TRY only opens a nesting level and it is CATCH that adds to CCN, so an @try/@catch currently scores the same as no error handling at all. catch_kinds=frozenset({"catch_clause"}). Also for_in_statement is dead: for (NSString *k in keys) parses as for_statement in this grammar, so the entry never fires.

F# counts functions correctly but cannot name them. Both functions in a two-function module come back as <anonymous>, because the name sits under function_declaration_left rather than on function_or_value_defn itself. Worth checking whether the generic name probe can reach it before this lands, since an unnamed row is not much use in a report. The CCN numbers were also uneven in a way I could not explain from the map alone:

if only       -> [('<anonymous>', 1)]
if + for      -> [('<anonymous>', 3)]
match 3 arms  -> [('<anonymous>', 1)]
try/with      -> [('<anonymous>', 1)]

The for counts, but a function whose whole body is one if scores 1. The match case is expected (flat arms count once for the dispatch, the docstring says so) and try/with matches the ObjC catch gap.

The general point, which is why I am not merging on green: CI passing tells you the maps import, not that they are right. A handful of table-driven cases per language, source in and expected ccn out, would have caught all three of these and would make the next language cheap. Happy to look again as soon as it is pushed.

@RaghavChamadiya

RaghavChamadiya commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Correcting my comment above, which I wrote without reading the review before it. That review stands, and this should not have gone in in this state. The claim I made about it being safe because 0.50.0 re-scores anyway is backwards: the re-score is what makes it worse, not better.

To be concrete about what is now on main in 549d133, since nothing was pushed here after 7 September:

  • _ELIXIR still has function_kinds={"call"} with an empty branch_kinds, so the collapse described above is live. Every Elixir file reports one function named defmodule at ccn 1, and the real functions are invisible.
  • _OBJC still carries declaration in function_kinds, so file-scope globals count as functions of complexity 1, and catch_kinds is still empty, so @try/@catch scores the same as no error handling.
  • _FSHARP has the same empty catch_kinds, and its functions still come back unnamed.

This matters more than usual this week. 0.50.0 moves HEALTH_ANALYZER_VERSION to 10, so every index re-scores on its next update and these numbers get persisted rather than merely displayed. A wrong value on disk is the thing the "no entry means no rows" default was protecting against.

A follow-up will drop _ELIXIR and apply the two Objective-C fixes from the review before the release ships.

@krishna231122-del to be clear, this is on me and not on you: the review above was the right call and I talked past it. The Objective-C and F# work is close, and that review lists exactly what each one needs. If you would like to take the follow-up yourself, say the word and it is yours.

@RaghavChamadiya
RaghavChamadiya merged commit 549d133 into repowise-dev:main Sep 11, 2026
9 checks passed
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.

2 participants