Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Addresses code review feedback on PR #42 to remove all exception handling from the CalculaBaseCalculoIbsCbs class.

Changes

  • Removed all try-catch blocks from 4 calculation methods:
    • CalcularValorPis()
    • CalcularValorCofins()
    • CalcularValorIcms()
    • CalcularValorIssqn()
  • Removed the using System; directive (no longer needed)
// Before
private decimal CalcularValorPis()
{
    try
    {
        var tributacaoPis = new TributacaoPis(_tributavel, _tipoDesconto);
        return tributacaoPis.Calcula().Valor;
    }
    catch
    {
        // Em caso de erro no cálculo, retorna 0 para não impactar o cálculo do IBS/CBS
        return 0m;
    }
}

// After  
private decimal CalcularValorPis()
{
    var tributacaoPis = new TributacaoPis(_tributavel, _tipoDesconto);
    return tributacaoPis.Calcula().Valor;
}

⚠️ Breaking Change

This is a breaking behavioral change. Previously, these methods would silently return 0 on any exception. Now, any exceptions from the calculation methods will propagate to calling code, allowing proper error handling at a higher level in the application.

Testing

  • ✅ Build successful for all target frameworks (net45, net48, net6.0, net8.0)
  • ✅ All 143 unit tests pass on .NET 8.0
  • ✅ No security vulnerabilities detected

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: robertorp <10251705+robertorp@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP to address feedback on reforma tributária implementation Fix generic catch clause in CalculaBaseCalculoIbsCbs Nov 6, 2025
Copilot AI requested a review from robertorp November 6, 2025 18:57
@robertorp robertorp marked this pull request as ready for review November 6, 2025 18:58
@robertorp
Copy link
Collaborator

@copilot remova todos try catch CalculaBaseCalculoIbsCbs

Co-authored-by: robertorp <10251705+robertorp@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 6, 2025

@copilot remova todos try catch CalculaBaseCalculoIbsCbs

Concluído em bec1482. Removi todos os blocos try-catch de CalculaBaseCalculoIbsCbs (4 métodos: CalcularValorPis, CalcularValorCofins, CalcularValorIcms e CalcularValorIssqn). Todos os 143 testes continuam passando.

Copilot AI changed the title Fix generic catch clause in CalculaBaseCalculoIbsCbs Remove all try-catch blocks from CalculaBaseCalculoIbsCbs Nov 6, 2025
@robertorp robertorp merged commit 08a27ad into ra/feat-reforma-tributaria Nov 6, 2025
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.

2 participants