|
| 1 | +# `tools` Command Spec |
| 2 | + |
| 3 | +## Purpose |
| 4 | +List all tools available for a repository and their status (enabled/disabled, using configuration file or not) |
| 5 | + |
| 6 | + |
| 7 | +## Usage |
| 8 | +``` |
| 9 | +codacy tools <provider> <organization> <repository> |
| 10 | +codacy tools gh my-org my-repo --output json |
| 11 | +``` |
| 12 | + |
| 13 | +## API Endpoints |
| 14 | +- [`listRepositoryTools`](https://api.codacy.com/api/api-docs#listrepositorytools) |
| 15 | + |
| 16 | +## Considerations |
| 17 | +- Tools can be enabled by users for that specific repository, or by an applied Coding Standard. |
| 18 | +- Tools may support local configuration files; if so, they would indicate if a configuration file was detected and if it is being used. |
| 19 | + |
| 20 | + |
| 21 | +## Output |
| 22 | + |
| 23 | +List first all enabled tools for the repository (under a title "✅ Enabled tools"), then all disabled tools for the repository (under a title "❌ Disabled tools"). |
| 24 | + |
| 25 | +For each tool, show the following information: |
| 26 | +- Tool name |
| 27 | +- If enabled in a Coding Standard, show the Coding Standard name |
| 28 | +- Tool configuration file status (Available, Not Available, Applied) |
| 29 | +- Notes |
| 30 | + - if the tool is client-side, show 'Client-side tool' |
| 31 | + |
| 32 | +# `tool` Command Spec |
| 33 | +## Purpose |
| 34 | +Enable or disable a specific tool for a repository. |
| 35 | + |
| 36 | +## Usage |
| 37 | +``` |
| 38 | +codacy tool <provider> <organization> <repository> <tool name> --enable |
| 39 | +codacy tool <provider> <organization> <repository> <tool name> --disable |
| 40 | +codacy tool <provider> <organization> <repository> <tool name> --configuration-file true |
| 41 | +``` |
| 42 | + |
| 43 | +### Options |
| 44 | +- `--enable, -e` |
| 45 | +- `--disable, -d` |
| 46 | +- `--configuration-file, -cf <true/false>` |
| 47 | + |
| 48 | +### Output |
| 49 | +If successful, return a success message with the action taken ("Tool X enabled", "Tool X uses now a configuration file", etc). Otherwise, return an error message with the error details provided by the API. |
| 50 | + |
| 51 | + |
| 52 | +## API Endpoints |
| 53 | +- [`configureTool`](https://api.codacy.com/api/api-docs#configuretool) |
| 54 | + |
| 55 | +## Considerations |
| 56 | +The API expects a tool UUID, not the tool name, so we need to fetch the tool UUID first. We can do this by calling the [`listRepositoryTools`](https://api.codacy.com/api/api-docs#listrepositorytools) API endpoint. We should match the tool name by "best match" using the `name` field. |
| 57 | + |
| 58 | +e.g. |
| 59 | +- for `trivy`, we'll match the tool called "Trivy" |
| 60 | +- for `eslint`, we'll match the tool called "ESLint", but not the tool called "ESLint (deprecated)" nor the tool called "ESLint9" |
| 61 | +- for `jackson`, we'll match the tool called "Jackson Linter" |
| 62 | +- to match a tool with spaces in the name, the user needs to replace the spaces with a hyphen `-`; e.g. `eslint-(deprecated)` should match the tool called "ESLint (deprecated)" |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +# `patterns` Command Spec |
| 67 | + |
| 68 | +## Purpose |
| 69 | +List all tool patterns for a repository and their status (enabled/disabled, parameters) |
| 70 | + |
| 71 | +## Options |
| 72 | +- `--languages <languages>` |
| 73 | +- `--categories <categories>` |
| 74 | +- `--severities <severities>` |
| 75 | +- `--tags <tags>` |
| 76 | +- `--search <search>` |
| 77 | +- `--enabled` |
| 78 | +- `--disabled` |
| 79 | +- `--recommended` |
| 80 | + |
| 81 | +## Usage |
| 82 | +``` |
| 83 | +codacy patterns <provider> <organization> <repository> <tool name> |
| 84 | +codacy patterns gh my-org my-repo eslint |
| 85 | +codacy patterns gh my-org my-repo eslint ---categories security,errorprone --severities critical,high --search "sql injection" --disabled --recommended |
| 86 | +``` |
| 87 | + |
| 88 | +## API Endpoints |
| 89 | +- [`listRepositoryTools`](https://api.codacy.com/api/api-docs#listrepositorytools) |
| 90 | +- [`listRepositoryToolPatterns`](https://api.codacy.com/api/api-docs#listrepositorytoolpatterns) |
| 91 | + |
| 92 | +## Considerations |
| 93 | +Have the same considerations described in the `tool` command spec about matching the tool name. |
| 94 | + |
| 95 | + |
| 96 | +## Output |
| 97 | +Instead of a table, show a card-style format for each pattern. |
| 98 | +``` |
| 99 | +──────────────────────────────────────── |
| 100 | +{✅/❌} {Title in white if enabled, gray if disabled} ({id in dark gray}) | {Recommended? in purple} |
| 101 | + {Severity colored} | {Category} {SubCategory?} | {Languages} | {Tags} |
| 102 | + {Description} |
| 103 | +
|
| 104 | + Why? {Rationale} |
| 105 | + How to fix? {Solution} |
| 106 | +
|
| 107 | + <IF THERE ARE PARAMETERS SET AND PATTERN IS ENABLED> |
| 108 | + Parameters: |
| 109 | + - {Parameter name} = {Parameter value} |
| 110 | + ... |
| 111 | + </IF THERE ARE PARAMETERS SET AND PATTERN IS ENABLED> |
| 112 | +──────────────────────────────────────── |
| 113 | +``` |
| 114 | + |
| 115 | +- "Why?" and "How to fix?" should be in white; their content should be in dim gray |
| 116 | +- Sort the results by severity (Critical > High > Medium > Minor), then by recommended (true > false), then by title alphabetically |
| 117 | +- As with other commands, if the results return more than 100 items, show a pagination warning and suggest filters to use. |
| 118 | + |
| 119 | + |
| 120 | +#`pattern` Command Spec |
| 121 | +## Purpose |
| 122 | +Enable or disable a specific pattern for a repository, and set its parameters if available. |
| 123 | + |
| 124 | +## Usage |
| 125 | +``` |
| 126 | +codacy pattern <provider> <organization> <repository> <tool name> <pattern id> --enable |
| 127 | +codacy pattern <provider> <organization> <repository> <tool name> <pattern id> --disable |
| 128 | +codacy pattern <provider> <organization> <repository> <tool name> <pattern id> --parameter <parameter name> <parameter value> |
| 129 | +``` |
| 130 | + |
| 131 | +### Options |
| 132 | +- `--enable, -e` |
| 133 | +- `--disable, -d` |
| 134 | +- `--parameter, -p <parameter name> <parameter value>` |
| 135 | + |
| 136 | +## API Endpoints |
| 137 | +- [`configureTool`](https://api.codacy.com/api/api-docs#configuretool) |
| 138 | + |
| 139 | +## Considerations |
| 140 | +Have the same considerations described in the `tool` command spec about matching the tool name. |
0 commit comments