-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean dlint
flags
#15290
Clean dlint
flags
#15290
Conversation
590362a
to
e099263
Compare
changelog_begin changelog_end
e099263
to
d0a074f
Compare
else | ||
return Nothing | ||
dlintSettings :: DlintUsage -> IO ([Classify], Hint) | ||
dlintSettings DlintDisabled = pure ([], mempty @Hint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dlintSettings
now works with DlintUsage
instead of just the fields in DlintEnabled
, so it can return the empty settings for DlintDisabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question. Do we need the @Hint
here ?
defineNoFile $ \GetDlintSettings -> | ||
liftIO $ case usage of | ||
DlintEnabled dir enableOverrides -> dlintSettings dir enableOverrides | ||
DlintDisabled -> fail "linter configuration unspecified" | ||
liftIO $ dlintSettings usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now GetDlintSettings
can't fail
getDlintRulesFile :: DlintRulesFile -> IO FilePath | ||
getDlintRulesFile = \case | ||
DefaultDlintRulesFile -> locateRunfiles $ | ||
mainWorkspace </> "compiler" </> "damlc" </> "daml-ide-core" </> "dlint.yaml" | ||
ExplicitDlintRulesFile path -> pure path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously dlintSettings
simply got dlintDataDir :: FilePath
as an argument, so all callers had to set the value to something, 99% of the time to the result of locateRunfiles $ mainWorkspace </> "compiler" </> "damlc" </> "daml-ide-core"
. Now, dlintSettings
does a single lookup instead when dlintRulesFile = DefaultDlintRulesFile
.
(dlintDataDir </> "dlint.yaml") : maybeToList dlintYaml | ||
dlintRulesFile : hintFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the only reason for dlintDataDir
was to find the dlint.yaml
file directly inside it, now we just talk about the file directly. This has the benefit of allowing users to specify any file as the rules file instead of having to name it dlint.yaml
and specify the directory
@@ -152,9 +151,9 @@ runShakeTest = runShakeTestOpts id | |||
-- | Run shake test on freshly initialised shake service, with custom options. | |||
runShakeTestOpts :: (Daml.Options -> Daml.Options) -> Maybe SS.Handle -> ShakeTest () -> IO (Either ShakeTestError ShakeTestResults) | |||
runShakeTestOpts fOpts mbScenarioService (ShakeTest m) = do | |||
dlintDataDir <-locateRunfiles $ mainWorkspace </> "compiler/damlc/daml-ide-core" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer need to locateRunfiles
here
setDlintDataDir :: Options -> IO Options | ||
setDlintDataDir opts = do | ||
defaultDir <-locateRunfiles $ | ||
mainWorkspace </> "compiler/damlc/daml-ide-core" | ||
return $ case optDlintUsage opts of | ||
DlintEnabled _ _ -> opts | ||
DlintDisabled -> opts{optDlintUsage=DlintEnabled defaultDir True} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that cmdLint
only allows the user to change the configuration of the linter, but not to turn it off, we don't need to hardcode these
@@ -726,8 +762,7 @@ execRepl dars importPkgs mbLedgerConfig mbAuthToken mbAppId mbSslConf mbMaxInbou | |||
-- We change directory so make this absolute | |||
dars <- mapM makeAbsolute dars | |||
opts <- pure opts | |||
{ optDlintUsage = DlintDisabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that cmdRepl
forbids any linter flags, we don't need to hardcode it off here.
numProcessors | ||
(EnableScenarioService False) | ||
optPackageName | ||
disabledDlintUsageParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no linter flags for daml damlc docs
fromParsed | ||
<$> lastOr def (enableDlint <|> disableDlint) | ||
<*> dlintOptionsParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing the on/off flags separately from the options keeps the parser simple
@@ -196,8 +196,6 @@ getIntegrationTests registerTODO scenarioService = do | |||
let outdir = "compiler/damlc/output" | |||
createDirectoryIfMissing True outdir | |||
|
|||
dlintDataDir <- locateRunfiles $ mainWorkspace </> "compiler/damlc/daml-ide-core" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another place where we no longer need to locateRunfiles
clearDlintHintFiles = | ||
flag' NoDlintHintFiles | ||
( long "lint-no-hint-files" | ||
<> internal | ||
<> help "Use no hint files for linting. This also ignores any \ | ||
\implicit '.dlint.yaml' files" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since --lint-hint-file
above allows multiple files to be specified, it's useful to have a way to clear them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
This cleans up a few issues I found when looking at the lint-related options. The main ones are:
damlc
commands that don't care about lint options no longer accept any lint options.dlint.yaml
)..dlint.yaml
from the closest ancestor or the user's home directory.damlc lint
no longer accepts options to enable/disable linting.optDlintUsage
are no longer overridden by the compiler anywhere.