Skip to content

Commit 36db748

Browse files
authored
Merge pull request #35 from codacy/cleanup-cli
breaking: Remove pr-creation and cleanup readme
2 parents 02d9237 + f7a7eb6 commit 36db748

File tree

6 files changed

+5
-142
lines changed

6 files changed

+5
-142
lines changed

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
# codacy-cli-v2
22

3-
This is a POC for what could be a new CLI for us. The idea is to rely on the native tools and SARIF format instead of relying on Docker.
4-
5-
## Overview
6-
7-
The `codacy-cli-v2` is a command-line tool for Codacy that supports analyzing code using ESLint and uploading the results in SARIF format to Codacy. It provides two main commands: `analyze` and `upload`.
3+
The `codacy-cli-v2` is a command-line tool for Codacy that supports analyzing code using tools like ESLint and uploading the results in SARIF format to Codacy. It provides two main commands: `analyze` and `upload`.
84

95
### Commands
106

117
- **`analyze` Command**: Runs ESLint analysis on the codebase.
128
- `--output, -o`: Output file for the results.
139
- `--tool, -t`: Specifies the tool to run analysis with (e.g., ESLint).
1410
- `--format`: Output format (use 'sarif' for SARIF format to terminal).
15-
- `--fix, -f`: Automatically fixes issues when possible.
16-
- `--new-pr`: Creates a new GitHub PR with fixed issues.
11+
- `--fix`: Automatically fixes issues when possible.
1712

1813
- **`upload` Command With Project Token**: Uploads a SARIF file containing analysis results to Codacy.
1914
- `--sarif-path, -s`: Path to the SARIF report.
@@ -30,7 +25,7 @@ The `codacy-cli-v2` is a command-line tool for Codacy that supports analyzing co
3025

3126
### Important Concepts
3227

33-
- **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
28+
- **`.codacy/codacy.yaml`**: Configuration file to specify runtimes and tools versions for the CLI.
3429
```yaml
3530
runtimes:
3631
@@ -87,7 +82,7 @@ codacy-cli analyze --tool eslint --format sarif
8782
To store the results as SARIF in a file:
8883

8984
```bash
90-
codacy-cli analyze -t eslint -o eslint.sarif
85+
codacy-cli analyze -t eslint --format sarif -o eslint.sarif
9186
```
9287

9388
## Upload Results
@@ -101,4 +96,3 @@ codacy-cli upload -s path/to/your.sarif -c your-commit-uuid -t your-project-toke
10196
### Example Repository
10297

10398
As an example, you can check https://github.com/troubleshoot-codacy/eslint-test-examples for a repository that has an action relying on this CLI.
104-

cmd/analyze.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@ package cmd
33
import (
44
"codacy/cli-v2/config"
55
"codacy/cli-v2/tools"
6-
"codacy/cli-v2/utils"
76
"encoding/json"
87
"fmt"
98
"io"
109
"log"
1110
"net/http"
1211
"os"
13-
"os/exec"
1412

1513
"github.com/spf13/cobra"
1614
)
1715

1816
var outputFile string
1917
var toolToAnalyze string
2018
var autoFix bool
21-
var doNewPr bool
2219
var outputFormat string
2320
var sarifPath string
2421
var commitUuid string
@@ -97,8 +94,7 @@ func init() {
9794
analyzeCmd.Flags().StringVarP(&outputFile, "output", "o", "", "output file for the results")
9895
analyzeCmd.Flags().StringVarP(&toolToAnalyze, "tool", "t", "", "Which tool to run analysis with")
9996
analyzeCmd.Flags().StringVar(&outputFormat, "format", "", "Output format (use 'sarif' for SARIF format)")
100-
analyzeCmd.Flags().BoolVarP(&autoFix, "fix", "f", false, "Apply auto fix to your issues when available")
101-
analyzeCmd.Flags().BoolVar(&doNewPr, "new-pr", false, "Create a new PR on GitHub containing the fixed issues")
97+
analyzeCmd.Flags().BoolVar(&autoFix, "fix", false, "Apply auto fix to your issues when available")
10298
rootCmd.AddCommand(analyzeCmd)
10399
}
104100

@@ -208,13 +204,6 @@ var analyzeCmd = &cobra.Command{
208204
log.Fatal("Trying to run unsupported tool: ", toolToAnalyze)
209205
}
210206

211-
// can't create a new PR if there will be no changes/fixed issues
212-
if doNewPr && !autoFix {
213-
log.Fatal("Can't create a new PR with fixes without fixing issues. Use the '--fix' option.")
214-
} else if doNewPr {
215-
failIfThereArePendingChanges()
216-
}
217-
218207
eslint := config.Config.Tools()["eslint"]
219208
eslintInstallationDirectory := eslint.Info()["installDir"]
220209
nodeRuntime := config.Config.Runtimes()["node"]
@@ -230,18 +219,5 @@ var analyzeCmd = &cobra.Command{
230219
}
231220

232221
tools.RunEslint(workDirectory, eslintInstallationDirectory, nodeBinary, args, autoFix, outputFile, outputFormat)
233-
234-
if doNewPr {
235-
utils.CreatePr(false)
236-
}
237222
},
238223
}
239-
240-
func failIfThereArePendingChanges() {
241-
cmd := exec.Command("git", "status", "--porcelain")
242-
out, _ := cmd.Output()
243-
244-
if string(out) != "" {
245-
log.Fatal("There are pending changes, cannot proceed. Commit your pending changes.")
246-
}
247-
}

cmd/ping.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

utils/prCreator.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

utils/prCreator.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

utils/prCreator_test.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)