Skip to content

Implementing delete repository function #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

sartorijr92
Copy link
Contributor

@sartorijr92 sartorijr92 commented Jul 18, 2025

This pull request introduces a new feature to the kodus-ai repository, specifically implementing a delete repository function. The changes are made in the feat/delete-repository-config-button branch and are intended to be merged into the main branch.

Key changes include:

  1. New Use Case: A new use case, DeleteRepositoryCodeReviewParameterUseCase, is added to handle the deletion of a repository from a code review configuration. The logic involves fetching the configuration, removing the specified repository, and updating the configuration. Suggestions for improvement include adding null checks, using specific types instead of any, and translating comments to English.

  2. Use Case Integration: The new use case is integrated into the system by importing it and adding it to the UseCases export array in the index.ts file.

  3. New Endpoint: A new endpoint is introduced in the parameters.controller.ts file to facilitate the deletion of repository code review parameters. The implementation is consistent with existing patterns, with a recommendation to align the endpoint with RESTful API design principles.

  4. Data Transfer Object (DTO): A new DTO, DeleteRepositoryCodeReviewParameterDto, is created to manage the parameters required for deleting a repository code review. It includes repositoryId and teamId properties with basic string validation.

Overall, this pull request enhances the functionality of the application by allowing users to delete repositories from code review configurations, with considerations for improving code robustness and maintainability.

@sartorijr92 sartorijr92 self-assigned this Jul 18, 2025
Copy link

kodus-ai bot commented Jul 18, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

Comment on lines +54 to +65
const repositoryExists = codeReviewConfigValue.repositories?.some(
(repository: any) => repository.id === repositoryId,
);

if (!repositoryExists) {
throw new Error('Repository not found in configuration');
}

// Remover o repositório específico do array
const updatedRepositories = codeReviewConfigValue.repositories.filter(
(repository: any) => repository.id !== repositoryId,
);
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules medium

const repositoryExists = codeReviewConfigValue.repositories?.some(
    (repository: { id: string }) => repository.id === repositoryId,
);

if (!repositoryExists) {
    throw new Error('Repository not found in configuration');
}

// Remover o repositório específico do array
const updatedRepositories = codeReviewConfigValue.repositories.filter(
    (repository: { id: string }) => repository.id !== repositoryId,
);

The code uses any as the type for repository objects when iterating through codeReviewConfigValue.repositories. Using any bypasses TypeScript's type checking, which can lead to runtime errors and makes the code harder to understand and maintain. It's recommended to define a specific interface or type for the repository object and use it in the .some() and .filter() methods. This will improve type safety and code clarity.

Kody Rules Violation: Evitar uso de any

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@@ -1,5 +1,6 @@
import { CopyCodeReviewParameterUseCase } from './copy-code-review-parameter.use-case';
import { CreateOrUpdateParametersUseCase } from './create-or-update-use-case';
import { DeleteRepositoryCodeReviewParameterUseCase } from './delete-repository-code-review-parameter.use-case';
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules medium

import { DeleteRepositoryCodeReviewParameterUseCase } from './deleteRepositoryCodeReviewParameter.useCase';

The Kody Rules require that all new files follow the camelCase naming convention. The newly imported file 'delete-repository-code-review-parameter.use-case.ts' uses kebab-case. Please rename the file to 'deleteRepositoryCodeReviewParameter.useCase.ts' and update the import path accordingly to maintain consistency across the codebase.

Kody Rules Violation: Seguir padrão de nomenclatura de arquivos

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Comment on lines +125 to +131
@Post('/delete-repository-code-review-parameter')
public async deleteRepositoryCodeReviewParameter(
@Body()
body: DeleteRepositoryCodeReviewParameterDto,
) {
return this.deleteRepositoryCodeReviewParameterUseCase.execute(body);
}
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

    @Delete('/delete-repository-code-review-parameter')
    public async deleteRepositoryCodeReviewParameter(
        @Body()
        body: DeleteRepositoryCodeReviewParameterDto,
    ): Promise<unknown> {
        return this.deleteRepositoryCodeReviewParameterUseCase.execute(body);
    }

The endpoint /delete-repository-code-review-parameter uses the POST HTTP method for a deletion operation. According to REST principles, DELETE is the appropriate method for deleting resources. It's recommended to change @Post to @Delete. Additionally, the function is missing an explicit return type, which is required by our coding standards. An explicit Promise<unknown> return type has been added to comply with this rule.

Kody Rules Violation: Tipagem explícita de parâmetros e retornos

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Comment on lines +1 to +9
import { IsString } from 'class-validator';

export class DeleteRepositoryCodeReviewParameterDto {
@IsString()
repositoryId: string;

@IsString()
teamId: string;
}
Copy link

Choose a reason for hiding this comment

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

kody code-review Potential Issues high

import { IsString, IsNotEmpty } from 'class-validator';

export class DeleteRepositoryCodeReviewParameterDto {
    @IsString()
    @IsNotEmpty()
    readonly repositoryId: string;

    @IsString()
    @IsNotEmpty()
    readonly teamId: string;
}

The @IsString() decorator allows empty strings. For more robust validation, consider adding the @IsNotEmpty() decorator. Additionally, properties in a DTO that are not meant to be changed after initialization should be marked as readonly to enforce immutability, as per company guidelines.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Comment on lines +1 to +9
import { IsString } from 'class-validator';

export class DeleteRepositoryCodeReviewParameterDto {
@IsString()
repositoryId: string;

@IsString()
teamId: string;
}
Copy link

Choose a reason for hiding this comment

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

kody code-review Kody Rules medium

// filename: deleteRepositoryCodeReviewParameter.dto.ts
import { IsString } from 'class-validator';

export class DeleteRepositoryCodeReviewParameterDto {
    @IsString()
    repositoryId: string;

    @IsString()
    teamId: string;
}

The filename 'delete-repository-code-review-parameter.dto.ts' uses kebab-case. According to the Kody Rules, all new files must follow the camelCase naming convention. Please rename the file to 'deleteRepositoryCodeReviewParameter.dto.ts'.

Kody Rules Violation: Seguir padrão de nomenclatura de arquivos

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@sartorijr92 sartorijr92 merged commit fe7d7b9 into main Jul 18, 2025
1 check failed
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.

1 participant