code-base-investigator
code-base-investigator copied to clipboard
Refactor codebase dictionary into CodeBase class
Related issues
-
Closes #86. A
CodeBasetracks all source files in the directories. -
Closes #66. Since all tests had to be rewritten to use the
CodeBaseclass, I updated the paths. -
Progress towards #58.
CodeBaseusespathlibinternally to store and manipulate paths. The external interfaces still accept and return strings for now, but this is only temporary. We can move away from strings entirely once all interfaces acceptPath.
Proposed changes
- Add a new
CodeBaseclass storing all information about which directories make up a code base and which files should be excluded from analysis. - Move legacy functionality into
CodeBasewhere appropriate: whether a file should be excluded from analysis is now implemented via__contains__; and listing the contents of a code base is now implemented via__iter__. - Rewrite all tests to use
CodeBase. Note that most of the changes here are actually related to casting betweenPathand strings, required because some legacy internals do not consider these representations to be equivalent. - Update the documentation and worked example to highlight that tracking all source files in a directory may result in unexpected files being included in the analysis.
Note that although most uses of CodeBase here only use a single directory, the intent is to enable a list of explicit directories to be passed in the future as:
[codebase]
directories = [
"src1/",
"src2/",
]
...in order to support analysis of disjoint codebases, and to allow codebasin to be run from any directory.