Skip to content

Commit 7ef401b

Browse files
authored
Merge pull request #320 from codacy/am/feat/support-analyze-CY2939
breaking: Change spelling of the `analyse` command to `analyze` [CY-2939]
2 parents 6c29002 + 0cfa4ac commit 7ef401b

File tree

14 files changed

+91
-82
lines changed

14 files changed

+91
-82
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ cd codacy-analysis-cli-* && sudo make install
105105
### Script
106106

107107
```sh
108-
codacy-analysis-cli analyse \
108+
codacy-analysis-cli analyze \
109109
--tool <TOOL-SHORT-NAME> \
110110
--directory <SOURCE-CODE-PATH>
111111
```
112112

113113
### Java
114114

115115
```
116-
java -jar codacy-analysis-cli-assembly-{VERSION}.jar analyse \
116+
java -jar codacy-analysis-cli-assembly-{VERSION}.jar analyze \
117117
--tool <TOOL-SHORT-NAME> \
118118
--directory <SOURCE-CODE-PATH> \
119119
# other options
@@ -122,7 +122,7 @@ java -jar codacy-analysis-cli-assembly-{VERSION}.jar analyse \
122122
### Local
123123

124124
```sh
125-
sbt "codacyAnalysisCli/runMain com.codacy.analysis.cli.Main analyse --tool <TOOL-SHORT-NAME> --directory <SOURCE-CODE-PATH>"
125+
sbt "codacyAnalysisCli/runMain com.codacy.analysis.cli.Main analyze --tool <TOOL-SHORT-NAME> --directory <SOURCE-CODE-PATH>"
126126
```
127127

128128
### Docker
@@ -135,7 +135,7 @@ docker run \
135135
--volume "$CODACY_CODE":"$CODACY_CODE" \
136136
--volume /tmp:/tmp \
137137
codacy/codacy-analysis-cli \
138-
analyse --tool <TOOL-SHORT-NAME>
138+
analyze --tool <TOOL-SHORT-NAME>
139139
```
140140

141141

@@ -202,10 +202,10 @@ Found [Clone] 7 duplicated lines with 10 tokens:
202202

203203
### Commands and Configuration
204204

205-
* `analyse` - Run a Codacy analysis over a directory/files
205+
* `analyze` - Run a Codacy analysis over a directory/files
206206
* `--help` - Displays all the configuration options, their meaning and possible values.
207207
* `--verbose` - Run the tool with verbose output
208-
* `--tool` - Choose the tool to analyse the code (e.g. brakeman)
208+
* `--tool` - Choose the tool to analyze the code (e.g. brakeman)
209209
* `--directory` - Choose the directory to be analysed
210210
* `--codacy-api-base-url` or env.`CODACY_API_BASE_URL` - Change the Codacy installation API URL to retrieve the configuration (e.g. Enterprise installation)
211211
* `--output` - Send the output results to a file
@@ -244,7 +244,7 @@ You can find the project token in:
244244
* `Project -> Settings -> Integrations -> Add Integration -> Project API`
245245

246246
```sh
247-
codacy-analysis-cli analyse \
247+
codacy-analysis-cli analyze \
248248
--project-token <PROJECT-TOKEN> \
249249
--tool <TOOL-SHORT-NAME> \
250250
--directory <SOURCE-CODE-PATH>
@@ -260,7 +260,7 @@ You can find the project token in:
260260
The username and project name can be retrieved from the URL in Codacy.
261261

262262
```sh
263-
codacy-analysis-cli analyse \
263+
codacy-analysis-cli analyze \
264264
--api-token <PROJECT-TOKEN> \
265265
--username <USERNAME> \
266266
--project <PROJECT-NAME> \
@@ -340,6 +340,11 @@ sbt codacyCoverage
340340
sbt 'set version in codacyAnalysisCore := "<VERSION>"' 'set pgpPassphrase := Some("<SONATYPE_GPG_PASSPHRASE>".toCharArray)' codacyAnalysisCore/publishSigned
341341
sbt 'set version in codacyAnalysisCore := "<VERSION>"' sonatypeRelease
342342

343+
## Breaking Changes
344+
345+
- 4.0.0 - Rename `analyse` command to `analyze`. This is a breaking change if you are running the CLI by using the
346+
[jar](#java) or [`sbt`](#local), but not if you are using the [provided script](#script).
347+
343348
## What is Codacy
344349

345350
[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

bin/codacy-analysis-cli.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ analysis_file() {
6060
*)
6161
if [ ${is_filename} -eq 1 ]; then
6262
if [ -n "$filename" ]; then
63-
echo "Please provide only one file or directory to analyse" >&2
63+
echo "Please provide only one file or directory to analyze" >&2
6464
exit 1
6565
else
6666
is_filename=0
@@ -104,7 +104,11 @@ prep_args_with_output_absolute_path() {
104104
new_args="${new_args} ${OUTPUT}"
105105
fi
106106
else
107-
new_args="${new_args} ${arg}"
107+
if [ ${arg} == "analyse" ]; then
108+
new_args="${new_args} analyze"
109+
else
110+
new_args="${new_args} ${arg}"
111+
fi
108112
fi
109113
;;
110114
esac

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ lazy val codacyAnalysisCore = project
4848
// Test Dependencies
4949
libraryDependencies ++= Dependencies.specs2,
5050
sonatypeInformation,
51-
description := "Library to analyse projects")
51+
description := "Library to analyze projects")
5252
.settings(assemblyCommon: _*)
5353
// Disable legacy Scalafmt plugin imported by codacy-sbt-plugin
5454
.disablePlugins(com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin)

cli/src/main/scala/com/codacy/analysis/cli/Main.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.codacy.analysis.cli.command.{AnalyseCommand, CLIApp, _}
55

66
object Main extends MainImpl()
77

8-
class MainImpl(analyseCommand: Analyse => AnalyseCommand = AnalyseCommand(_, sys.env),
8+
class MainImpl(analyseCommand: Analyze => AnalyseCommand = AnalyseCommand(_, sys.env),
99
validateConfigurationCommand: ValidateConfiguration => ValidateConfigurationCommand =
1010
ValidateConfigurationCommand(_))
1111
extends CLIApp {
@@ -16,7 +16,7 @@ class MainImpl(analyseCommand: Analyse => AnalyseCommand = AnalyseCommand(_, sys
1616

1717
def runCommand(command: CommandOptions): ExitStatus.ExitCode = {
1818
command match {
19-
case analyse: Analyse => analyseCommand(analyse).run()
19+
case analyze: Analyze => analyseCommand(analyze).run()
2020
case validateConfiguration: ValidateConfiguration =>
2121
validateConfigurationCommand(validateConfiguration).run()
2222
}

cli/src/main/scala/com/codacy/analysis/cli/command/AnalyseCommand.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,38 @@ import scala.util.{Failure, Success, Try}
3333

3434
object AnalyseCommand {
3535

36-
def apply(analyse: Analyse, env: Map[String, String]): AnalyseCommand = {
36+
def apply(analyze: Analyze, env: Map[String, String]): AnalyseCommand = {
3737
val environment: Environment = new Environment(env)
3838
val codacyClientOpt: Option[CodacyClient] =
39-
Credentials.get(environment, analyse.api).map(CodacyClient.apply)
39+
Credentials.get(environment, analyze.api).map(CodacyClient.apply)
4040
val configuration: CLIConfiguration =
41-
CLIConfiguration(codacyClientOpt, environment, analyse, new CodacyConfigurationFileLoader)
41+
CLIConfiguration(codacyClientOpt, environment, analyze, new CodacyConfigurationFileLoader)
4242
val formatter: Formatter =
43-
Formatter(configuration.analysis.output, environment.baseProjectDirectory(analyse.directory))
43+
Formatter(configuration.analysis.output, environment.baseProjectDirectory(analyze.directory))
4444
val fileCollector: FileCollector[Try] = FileCollector.defaultCollector()
4545
val analyseExecutor: AnalyseExecutor =
46-
new AnalyseExecutor(formatter, Analyser(analyse.extras.analyser), fileCollector, configuration.analysis)
46+
new AnalyseExecutor(formatter, Analyser(analyze.extras.analyser), fileCollector, configuration.analysis)
4747
val uploaderOpt: Either[String, Option[ResultsUploader]] =
4848
ResultsUploader(codacyClientOpt, configuration.upload.upload, configuration.upload.commitUuid)
4949

50-
new AnalyseCommand(analyse, configuration, analyseExecutor, uploaderOpt)
50+
new AnalyseCommand(analyze, configuration, analyseExecutor, uploaderOpt)
5151
}
5252
}
5353

54-
class AnalyseCommand(analyse: Analyse,
54+
class AnalyseCommand(analyze: Analyze,
5555
configuration: CLIConfiguration,
5656
analyseExecutor: AnalyseExecutor,
5757
uploaderOpt: Either[String, Option[ResultsUploader]]) {
5858

59-
Logger.setLevel(analyse.options.verboseValue)
59+
Logger.setLevel(analyze.options.verboseValue)
6060

6161
private val logger: org.log4s.Logger = getLogger
6262

6363
def run(): ExitStatus.ExitCode = {
6464
removeCodacyRuntimeConfigurationFiles(configuration.analysis.projectDirectory)
6565

6666
val analysisAndUpload = for {
67-
_ <- validate(analyse, configuration)
67+
_ <- validate(analyze, configuration)
6868
analysisResults <- analyseExecutor.run()
6969
_ <- upload(configuration.upload, analysisResults)
7070
} yield analysisResults
@@ -75,7 +75,7 @@ class AnalyseCommand(analyse: Analyse,
7575
.exitCode(analysisAndUpload)
7676
}
7777

78-
private def validate(analyse: Analyse, configuration: CLIConfiguration): Either[CLIError, Unit] = {
78+
private def validate(analyze: Analyze, configuration: CLIConfiguration): Either[CLIError, Unit] = {
7979
Git
8080
.repository(configuration.analysis.projectDirectory)
8181
.fold(
@@ -85,7 +85,7 @@ class AnalyseCommand(analyse: Analyse,
8585
{ repository =>
8686
for {
8787
_ <- validateNoUncommitedChanges(repository, configuration.upload.upload)
88-
_ <- validateGitCommitUuid(repository, analyse.commitUuid)
88+
_ <- validateGitCommitUuid(repository, analyze.commitUuid)
8989
} yield ()
9090
})
9191
}

cli/src/main/scala/com/codacy/analysis/cli/command/CLIApp.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ final case class ExtraOptions(
120120
@Hidden @ValueDescription(s"The analyser to use. (${Analyser.allAnalysers.map(_.name).mkString(", ")})")
121121
analyser: String = Analyser.defaultAnalyser.name)
122122

123-
final case class Analyse(
123+
final case class Analyze(
124124
@Recurse
125125
options: CommonOptions,
126126
@Recurse
127127
api: APIOptions,
128-
@ExtraName("t") @ValueDescription(s"The tool to analyse the code. (${Tool.allToolShortNames.mkString(", ")})")
128+
@ExtraName("t") @ValueDescription(s"The tool to analyze the code. (${Tool.allToolShortNames.mkString(", ")})")
129129
tool: Option[String],
130-
@ExtraName("d") @ValueDescription("The directory to analyse.")
130+
@ExtraName("d") @ValueDescription("The directory to analyze.")
131131
directory: Option[File],
132132
@ExtraName("f") @ValueDescription(s"The output format. (${Formatter.allFormatters.map(_.name).mkString(", ")})")
133133
format: String = Formatter.defaultFormatter.name,

cli/src/main/scala/com/codacy/analysis/cli/configuration/CLIConfiguration.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.codacy.analysis.cli.configuration
33
import better.files.File
44
import cats.Foldable
55
import cats.implicits._
6-
import com.codacy.analysis.cli.command.Analyse
6+
import com.codacy.analysis.cli.command.Analyze
77
import com.codacy.analysis.core.clients.CodacyClient
88
import com.codacy.analysis.core.clients.api._
99
import com.codacy.analysis.core.configuration.{
@@ -41,22 +41,22 @@ object CLIConfiguration {
4141
object Analysis {
4242

4343
def apply(projectDirectory: File,
44-
analyse: Analyse,
44+
analyze: Analyze,
4545
localConfiguration: Either[String, CodacyConfigurationFile],
4646
remoteProjectConfiguration: Either[String, ProjectConfiguration],
4747
tmpDirectory: Option[File]): Analysis = {
4848

4949
val fileExclusionRules =
5050
CLIConfiguration.FileExclusionRules(localConfiguration, remoteProjectConfiguration)
51-
val output = CLIConfiguration.Output(analyse.format, analyse.output, analyse.ghCodeScanningCompatValue)
51+
val output = CLIConfiguration.Output(analyze.format, analyze.output, analyze.ghCodeScanningCompatValue)
5252
val toolConfiguration =
53-
CLIConfiguration.Tool(analyse, localConfiguration, remoteProjectConfiguration)
53+
CLIConfiguration.Tool(analyze, localConfiguration, remoteProjectConfiguration)
5454
CLIConfiguration.Analysis(
5555
projectDirectory,
5656
output,
57-
analyse.tool,
58-
analyse.parallel,
59-
analyse.forceFilePermissionsValue,
57+
analyze.tool,
58+
analyze.parallel,
59+
analyze.forceFilePermissionsValue,
6060
fileExclusionRules,
6161
toolConfiguration,
6262
tmpDirectory)
@@ -124,7 +124,7 @@ object CLIConfiguration {
124124

125125
object Tool {
126126

127-
def apply(analyse: Analyse,
127+
def apply(analyze: Analyze,
128128
localConfiguration: Either[String, CodacyConfigurationFile],
129129
remoteProjectConfiguration: Either[String, ProjectConfiguration]): CLIConfiguration.Tool = {
130130

@@ -141,8 +141,8 @@ object CLIConfiguration {
141141
localConfiguration.map(_.languageCustomExtensions).getOrElse(Map.empty[Language, Set[String]])
142142

143143
CLIConfiguration.Tool(
144-
analyse.toolTimeout,
145-
analyse.allowNetworkValue,
144+
analyze.toolTimeout,
145+
analyze.allowNetworkValue,
146146
toolConfigurations,
147147
enginesConfiguration,
148148
languageExtensions)
@@ -191,11 +191,11 @@ object CLIConfiguration {
191191

192192
def apply(clientOpt: Option[CodacyClient],
193193
environment: Environment,
194-
analyse: Analyse,
194+
analyze: Analyze,
195195
localConfigLoader: CodacyConfigurationFileLoader): CLIConfiguration = {
196-
val projectDirectory: File = environment.baseProjectDirectory(analyse.directory)
196+
val projectDirectory: File = environment.baseProjectDirectory(analyze.directory)
197197
val commitUuid: Option[Commit.Uuid] =
198-
analyse.commitUuid.orElse(Git.currentCommitUuid(projectDirectory))
198+
analyze.commitUuid.orElse(Git.currentCommitUuid(projectDirectory))
199199

200200
val localConfiguration: Either[String, CodacyConfigurationFile] =
201201
localConfigLoader.load(projectDirectory)
@@ -205,9 +205,9 @@ object CLIConfiguration {
205205
_.getRemoteConfiguration
206206
}
207207
val analysisConfiguration =
208-
Analysis(projectDirectory, analyse, localConfiguration, remoteProjectConfiguration, analyse.tmpDirectory)
209-
val uploadConfiguration = Upload(commitUuid, analyse.uploadValue)
210-
val resultConfiguration = Result(analyse.maxAllowedIssues, analyse.failIfIncompleteValue)
208+
Analysis(projectDirectory, analyze, localConfiguration, remoteProjectConfiguration, analyze.tmpDirectory)
209+
val uploadConfiguration = Upload(commitUuid, analyze.uploadValue)
210+
val resultConfiguration = Result(analyze.maxAllowedIssues, analyze.failIfIncompleteValue)
211211

212212
CLIConfiguration(analysisConfiguration, uploadConfiguration, resultConfiguration)
213213
}

cli/src/test/scala/com/codacy/analysis/cli/AnalyseExecutorSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AnalyseExecutorSpec extends Specification with NoLanguageFeatures with Moc
2626
val pyLintPatternsInternalIds = Set("PyLint_C0111", "PyLint_E1101")
2727
val pathToIgnore = "lib/improver/tests/"
2828

29-
s"""|analyse a python project with pylint, using a remote project configuration retrieved with a project token
29+
s"""|analyze a python project with pylint, using a remote project configuration retrieved with a project token
3030
| that ignores the files that start with the path $pathToIgnore
3131
| and considers just patterns ${pyLintPatternsInternalIds.mkString(", ")}""".stripMargin in {
3232
val commitUuid = "9232dbdcae98b19412c8dd98c49da8c391612bfa"
@@ -75,7 +75,7 @@ class AnalyseExecutorSpec extends Specification with NoLanguageFeatures with Moc
7575
val esLintPatternsInternalIds =
7676
Set("ESLint_semi", "ESLint_no-undef", "ESLint_indent", "ESLint_no-empty")
7777

78-
s"""|analyse a javascript project with eslint, using a remote project configuration retrieved with an api token
78+
s"""|analyze a javascript project with eslint, using a remote project configuration retrieved with an api token
7979
| that considers just patterns ${esLintPatternsInternalIds.mkString(", ")}""".stripMargin in {
8080
val commitUuid = "9232dbdcae98b19412c8dd98c49da8c391612bfa"
8181
withClonedRepo("git://github.com/qamine-test/Monogatari.git", commitUuid) { (file, directory) =>
@@ -116,7 +116,7 @@ class AnalyseExecutorSpec extends Specification with NoLanguageFeatures with Moc
116116

117117
val cssLintPatternsInternalIds = Set("CSSLint_important")
118118

119-
"analyse a javascript and css project" in {
119+
"analyze a javascript and css project" in {
120120
val commitUuid = "9232dbdcae98b19412c8dd98c49da8c391612bfa"
121121
withClonedRepo("git://github.com/qamine-test/Monogatari.git", commitUuid) { (file, directory) =>
122122
val configuration = analysisConfiguration(

0 commit comments

Comments
 (0)