-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestion to run wget with --progress=dot:giga
Fixes #546 Warn when runnign wget without without --progress flag unless other flags are present (such as quiet/no-verbose/output/append), which usually leads to insane amouts of useless logs when downloaded files are big (usually anything over 5MB becomes annoying) Adding --progress=dot:giga makes output much shorter even for very large files such as AM/ML models etc. See wget manual, search for --progress=dot:giga Signed-off-by: Michał Sochoń <kaszpir@gmail.com>
- Loading branch information
1 parent
4db396c
commit 51ee880
Showing
5 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Hadolint.Rule.DL3047 (rule) where | ||
|
||
import Hadolint.Rule | ||
import Hadolint.Shell (ParsedShell) | ||
import qualified Hadolint.Shell as Shell | ||
import Language.Docker.Syntax | ||
|
||
rule :: Rule ParsedShell | ||
rule = simpleRule code severity message check | ||
where | ||
code = "DL3047" | ||
severity = DLWarningC | ||
message = | ||
"Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`.\ | ||
\Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`)." | ||
|
||
check (Run (RunArgs args _)) = foldArguments (Shell.noCommands forgotProgress) args | ||
check _ = True | ||
|
||
forgotProgress cmd = isWget cmd && (not (hasProgressOption cmd) && not (hasSpecialFlags cmd)) | ||
isWget (Shell.Command name _ _) = name == "wget" | ||
hasProgressOption cmd = Shell.hasFlag "progress" cmd | ||
|
||
hasSpecialFlags cmd = | ||
hasQuietFlag cmd | ||
|| hasOutputFlag cmd | ||
|| hasAppendOutputFlag cmd | ||
|| hasNoVerboseFlag cmd | ||
|
||
hasQuietFlag cmd = Shell.hasAnyFlag ["q", "quiet"] cmd | ||
hasOutputFlag cmd = Shell.hasAnyFlag ["o", "output-file"] cmd | ||
hasAppendOutputFlag cmd = Shell.hasAnyFlag ["a", "append-output"] cmd | ||
hasNoVerboseFlag cmd = | ||
Shell.hasAnyFlag ["no-verbose"] cmd | ||
|| Shell.cmdHasArgs "wget" ["-nv"] cmd | ||
{-# INLINEABLE rule #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters