Well, here's something I could extract from it, and maybe this can even be automated:
Distance between variable declaration and its use. But, oh, distances aren't simple either:
LoCs seem like a reasonable unit to count the distance between use and declaration, but are all LoCs equal? Should the metric penalize less for having long JavaDoc-style comments (which a lot of editors can simply collapse?) What about empty lines? -- seems even more contentious. Penalizing for lines of code regardless of contents of those lines will probably discourage programmers from adding empty lines even when they might make things better. Perhaps a better unit of measurement should be "statements"?
Now, why would using variables deep inside nested blocks be equivalent to using them same distance away but inside the same block? I'd say that probably declaring all your loop variables outside of the outermost loop sounds like a crime to me. Sure, the nesting level should be accounted for.
What do we do with class variables / struct fields though? Someone who wants to game the metric can simply decide that instead of using variables they'd store everything as a struct field. But, if we treat struct fields as variables... ouch, structs are meant to "transfer" bunches of variables from place to place, so, they will definitely score worse than function-local variables... How'd I find good ratio to balance struct fields against the variables? How'd measuring distance in LoCs or instructions coexist with mentions in different files, different directories even? What if it's like a define? Especially a popular one, like "TRUE" in C? -- That variable would pull out such a huge score...
----
I don't think these questions are impossible to answer. But I cannot even imagine the research plan to try to come up with some concrete numbers, ratios, functions to make this thing work...
Distance between variable declaration and its use. But, oh, distances aren't simple either:
LoCs seem like a reasonable unit to count the distance between use and declaration, but are all LoCs equal? Should the metric penalize less for having long JavaDoc-style comments (which a lot of editors can simply collapse?) What about empty lines? -- seems even more contentious. Penalizing for lines of code regardless of contents of those lines will probably discourage programmers from adding empty lines even when they might make things better. Perhaps a better unit of measurement should be "statements"?
Now, why would using variables deep inside nested blocks be equivalent to using them same distance away but inside the same block? I'd say that probably declaring all your loop variables outside of the outermost loop sounds like a crime to me. Sure, the nesting level should be accounted for.
What do we do with class variables / struct fields though? Someone who wants to game the metric can simply decide that instead of using variables they'd store everything as a struct field. But, if we treat struct fields as variables... ouch, structs are meant to "transfer" bunches of variables from place to place, so, they will definitely score worse than function-local variables... How'd I find good ratio to balance struct fields against the variables? How'd measuring distance in LoCs or instructions coexist with mentions in different files, different directories even? What if it's like a define? Especially a popular one, like "TRUE" in C? -- That variable would pull out such a huge score...
----
I don't think these questions are impossible to answer. But I cannot even imagine the research plan to try to come up with some concrete numbers, ratios, functions to make this thing work...