Assuming you’re ok with a ReasonML example?
My record is 22 indents (24 if you don’t count the formatter keeping some of it on one line). This is a HTML model test, written in mocha
. The test begins triple indented with test suite grouping, adds an extra local open indent for good measure, and creates a nested HTML table structure through model generation methods.
It’s using lists, but that’s only because we created our test framework before we realised arrays were better in JS. The framework is too widely used to migrate now and we figure the differences don’t matter as much in test code.
it("should empty table cells that are deep in the tree if selection has nested tables", () => {
testDeleteBackward(
~model=
SlateMarkup.(
toEditor([
block(
"table",
[
block(
"tbody",
[
block(
"tr",
[
block(
"td",
[
block(
"table",
[
block(
"tbody",
[
block(
"tr",
[
block("td", [text("ab")]),
block("td", [text("cd")]),
],
),
],
),
],
),
],
),
block("td", [text("cd")]),
],
),
],
),
],
),
])
),
~expectedModel=
SlateMarkup.(
toEditor([
block(
"table",
[
block(
"tbody",
[
block(
"tr",
[
block(
"td",
[
block(
"table",
[
block(
"tbody",
[
block(
"tr",
[
block("td", [text("")]),
block("td", [text("")]),
],
),
],
),
],
),
],
),
block("td", [text("")]),
],
),
],
),
],
),
])
),
~range=
makeRange(
~anchorPath=[0, 0, 0, 0, 0, 0, 0, 0, 0],
~anchorOffset=1,
~focusPath=[0, 0, 0, 1, 0],
~focusOffset=1,
),
)
});
});
Looking at it in isolation my first thought is perhaps it could be refactored to reduce the indentation, but that’s not a great idea in test code when the path
references at the bottom must be specific to the model structure. In these sorts of tests using specific inputs can avoid tests passing incorrectly.
Setting aside test code, which is arguably an unrealistic example even if it is production code, my record is 13 indents. This happens in nested promise-based networking code; the function is nearly 200 lines long and it’s way too complex to try to extract a realistic sample. It probably can be refactored to reduce the indenting, but the whole file has been flagged for a rewrite to fix technical debt.