mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-14 10:37:26 -07:00
Scan for Gentoo eclass variables
Creates a Map of eclass names to eclass variables by scanning the system for repositories and their respective eclasses. Runs `portageq` to determine repository names and locations. Emits a warning if an IOException is caught when attempting to run `portageq`. This Map is passed via CheckSpec to AnalysisSpec and finally to Parameters, where it is read by `checkUnusedAssignments` in order to determine which variables can be safely ignored by this check. Signed-off-by: hololeap <hololeap@users.noreply.github.com>
This commit is contained in:
parent
08ae7ef836
commit
272ef819b9
8 changed files with 58 additions and 18 deletions
|
@ -21,6 +21,7 @@ import qualified ShellCheck.Analyzer
|
|||
import ShellCheck.Checker
|
||||
import ShellCheck.Data
|
||||
import ShellCheck.Interface
|
||||
import ShellCheck.PortageVariables
|
||||
import ShellCheck.Regex
|
||||
|
||||
import qualified ShellCheck.Formatter.CheckStyle
|
||||
|
@ -240,10 +241,22 @@ runFormatter sys format options files = do
|
|||
either (reportFailure filename) check input
|
||||
where
|
||||
check contents = do
|
||||
|
||||
-- If this is a Gentoo ebuild file, scan for eclasses on the system
|
||||
gentooData <- case getPortageFileType filename of
|
||||
NonPortageRelated -> pure Map.empty
|
||||
_ -> catch (portageVariables <$> scanRepos) $ \e -> do
|
||||
let warnMsg = "Error when scanning for Gentoo repos: "
|
||||
let err = show (e :: IOException)
|
||||
hPutStr stderr ("Warning: " ++ warnMsg ++ err)
|
||||
pure Map.empty
|
||||
|
||||
let checkspec = (checkSpec options) {
|
||||
csFilename = filename,
|
||||
csScript = contents
|
||||
csScript = contents,
|
||||
csGentooData = gentooData
|
||||
}
|
||||
|
||||
result <- checkScript sys checkspec
|
||||
onResult format result sys
|
||||
return $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue