Class CommandDetector
- java.lang.Object
-
- org.sonar.iac.docker.checks.utils.CommandDetector
-
public class CommandDetector extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommandDetector.Builderstatic classCommandDetector.Commandstatic classCommandDetector.SeparatedListBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandDetector.Builderbuilder()List<CommandDetector.Command>search(List<ArgumentResolution> resolvedArguments)Search for the defined command in resolved arguments.List<CommandDetector.Command>searchWithoutSplit(List<ArgumentResolution> resolvedArguments)Perform the same operation assearch(List), but it doesn't split arguments at the beginning.
-
-
-
Method Detail
-
builder
public static CommandDetector.Builder builder()
-
searchWithoutSplit
public List<CommandDetector.Command> searchWithoutSplit(List<ArgumentResolution> resolvedArguments)
Perform the same operation assearch(List), but it doesn't split arguments at the beginning.Implementation details:
A stack is formed on the basis of the arguments provided by a command instruction. This stack is processed until there are no more usable elements. The foremost element is taken from the stack and checked to see if it matches the command to be searched for.
-
search
public List<CommandDetector.Command> search(List<ArgumentResolution> resolvedArguments)
Search for the defined command in resolved arguments. Example:
It will find onlyList<ArgumentResolution> arguments = buildArgumentList("echo", "foo", "bar"); CommandDetector detector = CommandDetector.builder() .with("echo") .with("foo") .build(); detector.search(arguments);echoandfooand return as result.This method split arguments at the beginning i.e.:
echo foo && echo barwill be searched individually.
-
-