[x2cpg] SourceFiles.determine
too Coupled with X2CpgConfig
#3811
Labels
bug
Something isn't working
consistency
Concerns abstracting and adding tooling to unify duplicated or inconsistent code
help wanted
Extra attention is needed
Original report by @khemrajrathore
Describe the problem
Source Code
We have 4 overloaded variants of the
determine
function, many of which end up to one or two of the same ones, but thedetermine
function at LNo 57 and LNo 77 doesn’t use thefilterFiles
function, and it doesn’t seem correct to me.The function at LNo 57 is used at most places, which is not considering any exclusion rules provided in the field
withIgnoredFilesRegex
. This leaves theX2CpgConfig
silently/unintentionally unutilized.It is observed that there is a place for
determine
to be called withoutX2CpgConfig
, but it is mistakenly confused by frontends that ingest source code for processing.Desired Solution
Rename the function at LNo 57 to something like
determineAll
and replacing it with the function at LNo 64 where ever it is being called for processing files to be generated by the CPG. As well as inspect usages of LNo77 such that the result of the solution is that all frontends calldetermine
that make use of the config.Alternatives
Remove the function at LNo 57 and add another overloaded variant where the config is an optional argument so that developers are intentional about using it without
X2CpgConfig
Points from @fabsx00:
determine
at all. This adds extra coupling and implicit functionality.X2CpgConfig
properties are used, and by simply passing the whole config, it is unclear what it's being used for.The text was updated successfully, but these errors were encountered: