Skip to content

Conversation

@franciscoovazevedo
Copy link
Contributor

@franciscoovazevedo franciscoovazevedo commented Apr 7, 2025

Removed support for project-token (repository token).

@franciscoovazevedo franciscoovazevedo marked this pull request as draft April 7, 2025 13:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

.codacy/codacy.yaml:5

  • Verify that downgrading ESLint from 9.3.0 to 8.57.0 is intentional, as this may introduce compatibility issues if other parts of the project expect the newer version.

cmd/init.go:224

  • Consider including the HTTP status code or response details in the error message to improve debugging when the Codacy API call fails.
return errors.New("failed to get repository's configuration from Codacy API")

@franciscoovazevedo franciscoovazevedo changed the title feature: support use of codacy api token - PLUTO-1379 breaking: support use of codacy api token - PLUTO-1379 Apr 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • .codacy/cli-config.yaml: Language not supported
  • .codacy/codacy.yaml: Language not supported


for _, tool := range tools {
if tool.Uuid == "f8b29663-2cb2-498d-b923-a10c6a8c05cd" {
switch tool.Uuid {
Copy link

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch on tool.Uuid compares against string(ESLint), but ESLint is defined as 'eslint' in domain/toolName.go, which is not a UUID. Use the proper UUID constants (e.g. those defined as ToolUiid) for accurate comparisons.

Copilot uses AI. Check for mistakes.
cmd/init.go Outdated
Comment on lines 234 to 235
case string(ESLint):
if len(patternConfiguration) > 0 {
Copy link

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case statement compares tool.Uuid to string(ESLint) where the constant value 'eslint' does not match the expected UUID. Replace it with the correct UUID constant from ToolUiid to ensure proper matching.

Suggested change
case string(ESLint):
if len(patternConfiguration) > 0 {
case tools.ToolUuidESLint:

Copilot uses AI. Check for mistakes.
cmd/init.go Outdated

func init() {
initCmd.Flags().StringVar(&codacyRepositoryToken, "repository-token", "", "optional codacy repository token, if defined configurations will be fetched from codacy")
initCmd.Flags().StringVar(&codacyApiToken, "codacy-api-token", "", "optional codacy api token, if defined configurations will be fetched from codacy")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify it

Suggested change
initCmd.Flags().StringVar(&codacyApiToken, "codacy-api-token", "", "optional codacy api token, if defined configurations will be fetched from codacy")
initCmd.Flags().StringVar(&codacyApiToken, "api-token", "", "optional codacy api token, if defined configurations will be fetched from codacy")

cmd/init.go Outdated
func init() {
initCmd.Flags().StringVar(&codacyRepositoryToken, "repository-token", "", "optional codacy repository token, if defined configurations will be fetched from codacy")
initCmd.Flags().StringVar(&codacyApiToken, "codacy-api-token", "", "optional codacy api token, if defined configurations will be fetched from codacy")
initCmd.Flags().StringVar(&remoteProvider, "provider", "", "optional provider (gh/bb/gl), if defined configurations will be fetched from codacy")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can focus on a semantic of 'mandatory when the api-token is defined. Will help users and the model

cmd/init.go Outdated

// Create a new GET request
req, err := http.NewRequest("GET", url, nil)
apiTools, err := tools.GetRepositoryTools(CodacyApiBase, token, remoteProvider, remoteOrganizationName, remoteRepositoryName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it something like repositoryTools. We aligned that GetRepositoryTools returns the tools for the repository in question (the ones that we are interested, meaning the enabled ones), already filtered by what is supported on the CLI.

//Concepts:
repositoryTools + supportedToolsOnCLI => configuredRepositoryTools

//supportedToolsOnCLI
Come from the tools on the configuration .tools (config is available globally, but in some places we also pass it)

cmd/init.go Outdated
remoteRepositoryName,
tool.Uuid)

fmt.Printf("url: %q\n", url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably debug and remove?

cmd/init.go Outdated
},
)
createToolFileConfigurations(tool, apiToolConfigurations)
// TODO: Process the response and create configuration files for each tool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftovers delete

cmd/init.go Outdated

//ESLInt internal codacy uuid, to filter ot not ESLint tools
//"f8b29663-2cb2-498d-b923-a10c6a8c05cd"
eslintConfigFile, err := os.Create("eslint.config.mjs")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When rebasing the @andrzej-janczak PR (already merged) make sure you don't break the new path to create those config files

@franciscoovazevedo franciscoovazevedo force-pushed the api-token-pluto-1379 branch 2 times, most recently from 429f844 to b908087 Compare April 9, 2025 09:19
@codacy-production
Copy link

codacy-production bot commented Apr 9, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.25% 14.86%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (93219d2) 2260 600 26.55%
Head commit (eff63cf) 2274 (+14) 598 (-2) 26.30% (-0.25%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#58) 222 33 14.86%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@franciscoovazevedo franciscoovazevedo marked this pull request as ready for review April 9, 2025 09:24
@franciscoovazevedo franciscoovazevedo merged commit dd841e6 into main Apr 9, 2025
7 checks passed
@alerizzo alerizzo deleted the api-token-pluto-1379 branch June 3, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants