This is a task that defies static analysis. For example the not-unlikely code
def open_me(dir_path, filename, extension):
return open(dir_path + filename + extension)
would be a tough one to catch. When faced with an insoluble problem, use heuristics. I'd go both directions with this.
- Assume that every filename in the tree is a candidate for being referenced in every file. I'd also add to the candidates
someFile
for every `someFilesomeFile.js
. Then search the entire codebase for instances of the candidates and report them as possible defects which must be looked at. I recommend putting eyeballs in the loop because you don't want to catch comments and string literals which may not be filenames. Tedious? Sure. - The second direction is to look at every
open()
or similar function for filename-like things. This is tedious too.
There is only one way to prevent it happening in the future:
- Set a policy and enforce it through code reviews. You went to a new platform which has additional portability constraints. Because of the
open_me
gotcha above, additional discipline is needed by the development team.