Skip to content

Commit

Permalink
report-sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueUPT committed Dec 10, 2024
1 parent aeb61e7 commit 2de00d5
Showing 1 changed file with 96 additions and 71 deletions.
167 changes: 96 additions & 71 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
# Obtener datos de SonarCloud
SONAR_DATA=$(curl -s "https://sonarcloud.io/api/measures/component?component=JosueUPT_CalidadU2&metricKeys=bugs,vulnerabilities,code_smells,coverage,duplicated_lines_density,complexity,ncloc,cognitive_complexity,comment_lines_density,security_rating,reliability_rating,sqale_rating,development_cost,security_remediation_effort,reliability_remediation_effort,sqale_index,confirmed_issues,effort_to_reach_maintainability_rating_a")
# Extraer todos los valores disponibles
# Extraer valores
BUGS=$(echo $SONAR_DATA | jq -r '.component.measures[] | select(.metric == "bugs") | .value')
VULNERABILITIES=$(echo $SONAR_DATA | jq -r '.component.measures[] | select(.metric == "vulnerabilities") | .value')
CODE_SMELLS=$(echo $SONAR_DATA | jq -r '.component.measures[] | select(.metric == "code_smells") | .value')
Expand All @@ -91,11 +91,17 @@ jobs:
CONFIRMED_ISSUES=$(echo $SONAR_DATA | jq -r '.component.measures[] | select(.metric == "confirmed_issues") | .value')
EFFORT_TO_A=$(echo $SONAR_DATA | jq -r '.component.measures[] | select(.metric == "effort_to_reach_maintainability_rating_a") | .value')
# Verificar que los valores se obtuvieron
echo "Valores obtenidos:"
echo "Bugs: $BUGS"
echo "Coverage: $COVERAGE"
echo "Code Smells: $CODE_SMELLS"
mkdir -p public/sonar
echo "<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\">
<meta charset="UTF-8">
<title>Análisis SonarCloud</title>
<style>
body {
Expand Down Expand Up @@ -156,103 +162,122 @@ jobs:
</style>
</head>
<body>
<div class=\"container\">
<div class="container">
<h1>Análisis Detallado de Calidad del Código</h1>
<h2 class=\"section-title\">Métricas Principales</h2>
<div class=\"metric-grid\">
<div class=\"metric-card\">
<div class=\"metric-title\">Cobertura de Código</div>
<div class=\"metric-value info\">$COVERAGE%</div>
<div class=\"metric-detail\">$(echo \"100 - $COVERAGE\" | bc)% sin cobertura</div>
<h2 class="section-title">Métricas Principales</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-title">Cobertura de Código</div>
<div class="metric-value info">__COVERAGE__%</div>
<div class="metric-detail">$(echo "100 - __COVERAGE__" | bc)% sin cobertura</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Bugs</div>
<div class=\"metric-value good\">$BUGS</div>
<div class=\"metric-detail\">Problemas detectados</div>
<div class="metric-card">
<div class="metric-title">Bugs</div>
<div class="metric-value good">__BUGS__</div>
<div class="metric-detail">Problemas detectados</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Code Smells</div>
<div class=\"metric-value warning\">$CODE_SMELLS</div>
<div class=\"metric-detail\">Oportunidades de mejora</div>
<div class="metric-card">
<div class="metric-title">Code Smells</div>
<div class="metric-value warning">__CODE_SMELLS__</div>
<div class="metric-detail">Oportunidades de mejora</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Duplicación</div>
<div class=\"metric-value good\">$DUPLICATION%</div>
<div class=\"metric-detail\">Código duplicado</div>
<div class="metric-card">
<div class="metric-title">Duplicación</div>
<div class="metric-value good">__DUPLICATION__%</div>
<div class="metric-detail">Código duplicado</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Vulnerabilidades</div>
<div class=\"metric-value good\">$VULNERABILITIES</div>
<div class=\"metric-detail\">Vulnerabilidades detectadas</div>
<div class="metric-card">
<div class="metric-title">Vulnerabilidades</div>
<div class="metric-value good">__VULNERABILITIES__</div>
<div class="metric-detail">Vulnerabilidades detectadas</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Líneas de Código</div>
<div class=\"metric-value info\">$LINES</div>
<div class=\"metric-detail\">Total de líneas</div>
<div class="metric-card">
<div class="metric-title">Líneas de Código</div>
<div class="metric-value info">__LINES__</div>
<div class="metric-detail">Total de líneas</div>
</div>
</div>
<h2 class=\"section-title\">Métricas Avanzadas</h2>
<div class=\"metric-grid\">
<div class=\"metric-card\">
<div class=\"metric-title\">Complejidad Ciclomática</div>
<div class=\"metric-value info\">$COMPLEXITY</div>
<div class=\"metric-detail\">Total del proyecto</div>
<h2 class="section-title">Métricas Avanzadas</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-title">Complejidad Ciclomática</div>
<div class="metric-value info">__COMPLEXITY__</div>
<div class="metric-detail">Total del proyecto</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Complejidad Cognitiva</div>
<div class=\"metric-value info\">$COGNITIVE_COMPLEXITY</div>
<div class=\"metric-detail\">Dificultad de entendimiento</div>
<div class="metric-card">
<div class="metric-title">Complejidad Cognitiva</div>
<div class="metric-value info">__COGNITIVE_COMPLEXITY__</div>
<div class="metric-detail">Dificultad de entendimiento</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Densidad de Comentarios</div>
<div class=\"metric-value info\">${COMMENT_DENSITY}%</div>
<div class=\"metric-detail\">Código documentado</div>
<div class="metric-card">
<div class="metric-title">Densidad de Comentarios</div>
<div class="metric-value info">__COMMENT_DENSITY__%</div>
<div class="metric-detail">Código documentado</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Costo de Desarrollo</div>
<div class=\"metric-value info\">$DEVELOPMENT_COST</div>
<div class=\"metric-detail\">Valor estimado</div>
<div class="metric-card">
<div class="metric-title">Costo de Desarrollo</div>
<div class="metric-value info">__DEVELOPMENT_COST__</div>
<div class="metric-detail">Valor estimado</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Esfuerzo para Rating A</div>
<div class=\"metric-value info\">$EFFORT_TO_A min</div>
<div class=\"metric-detail\">Tiempo necesario</div>
<div class="metric-card">
<div class="metric-title">Esfuerzo para Rating A</div>
<div class="metric-value info">__EFFORT_TO_A__ min</div>
<div class="metric-detail">Tiempo necesario</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Problemas Confirmados</div>
<div class=\"metric-value good\">$CONFIRMED_ISSUES</div>
<div class=\"metric-detail\">Issues verificados</div>
<div class="metric-card">
<div class="metric-title">Problemas Confirmados</div>
<div class="metric-value good">__CONFIRMED_ISSUES__</div>
<div class="metric-detail">Issues verificados</div>
</div>
</div>
<h2 class=\"section-title\">Calificaciones y Esfuerzos</h2>
<div class=\"metric-grid\">
<div class=\"metric-card\">
<div class=\"metric-title\">Seguridad</div>
<div class=\"metric-value ${SECURITY_RATING == 1 ? 'good' : 'warning'}\">$([ \"$SECURITY_RATING\" = \"1\" ] && echo \"A\" || echo \"B+\")</div>
<div class=\"metric-detail\">Esfuerzo: $SECURITY_EFFORT min</div>
<h2 class="section-title">Calificaciones y Esfuerzos</h2>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-title">Seguridad</div>
<div class="metric-value ${SECURITY_RATING == 1 ? 'good' : 'warning'}">__([ "$SECURITY_RATING" = "1" ] && echo "A" || echo "B+")__</div>
<div class="metric-detail">Esfuerzo: __SECURITY_EFFORT__ min</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Confiabilidad</div>
<div class=\"metric-value ${RELIABILITY_RATING == 1 ? 'good' : 'warning'}\">$([ \"$RELIABILITY_RATING\" = \"1\" ] && echo \"A\" || echo \"B+\")</div>
<div class=\"metric-detail\">Esfuerzo: $RELIABILITY_EFFORT min</div>
<div class="metric-card">
<div class="metric-title">Confiabilidad</div>
<div class="metric-value ${RELIABILITY_RATING == 1 ? 'good' : 'warning'}">__([ "$RELIABILITY_RATING" = "1" ] && echo "A" || echo "B+")__</div>
<div class="metric-detail">Esfuerzo: __RELIABILITY_EFFORT__ min</div>
</div>
<div class=\"metric-card\">
<div class=\"metric-title\">Mantenibilidad</div>
<div class=\"metric-value ${MAINTAINABILITY_RATING == 1 ? 'good' : 'warning'}\">$([ \"$MAINTAINABILITY_RATING\" = \"1\" ] && echo \"A\" || echo \"B+\")</div>
<div class=\"metric-detail\">Deuda: $TECH_DEBT min</div>
<div class="metric-card">
<div class="metric-title">Mantenibilidad</div>
<div class="metric-value ${MAINTAINABILITY_RATING == 1 ? 'good' : 'warning'}">__([ "$MAINTAINABILITY_RATING" = "1" ] && echo "A" || echo "B+")__</div>
<div class="metric-detail">Deuda: __TECH_DEBT__ min</div>
</div>
</div>
<div style=\"text-align: right; margin-top: 30px; color: #666;\">
Última actualización: $(date \"+%Y-%m-%d %H:%M:%S\")
<div style="text-align: right; margin-top: 30px; color: #666;">
Última actualización: __$(date "+%Y-%m-%d %H:%M:%S")__
</div>
</div>
</body>
</html>" > public/sonar/index.html
# Reemplazar los valores
sed -i "s/__COVERAGE__/$COVERAGE/g" public/sonar/index.html
sed -i "s/__BUGS__/$BUGS/g" public/sonar/index.html
sed -i "s/__CODE_SMELLS__/$CODE_SMELLS/g" public/sonar/index.html
sed -i "s/__DUPLICATION__/$DUPLICATION/g" public/sonar/index.html
sed -i "s/__COMPLEXITY__/$COMPLEXITY/g" public/sonar/index.html
sed -i "s/__LINES__/$LINES/g" public/sonar/index.html
sed -i "s/__COGNITIVE_COMPLEXITY__/$COGNITIVE_COMPLEXITY/g" public/sonar/index.html
sed -i "s/__COMMENT_DENSITY__/$COMMENT_DENSITY/g" public/sonar/index.html
sed -i "s/__SECURITY_RATING__/$SECURITY_RATING/g" public/sonar/index.html
sed -i "s/__RELIABILITY_RATING__/$RELIABILITY_RATING/g" public/sonar/index.html
sed -i "s/__MAINTAINABILITY_RATING__/$MAINTAINABILITY_RATING/g" public/sonar/index.html
sed -i "s/__DEVELOPMENT_COST__/$DEVELOPMENT_COST/g" public/sonar/index.html
sed -i "s/__SECURITY_EFFORT__/$SECURITY_EFFORT/g" public/sonar/index.html
sed -i "s/__RELIABILITY_EFFORT__/$RELIABILITY_EFFORT/g" public/sonar/index.html
sed -i "s/__TECH_DEBT__/$TECH_DEBT/g" public/sonar/index.html
sed -i "s/__CONFIRMED_ISSUES__/$CONFIRMED_ISSUES/g" public/sonar/index.html
sed -i "s/__EFFORT_TO_A__/$EFFORT_TO_A/g" public/sonar/index.html
- name: Verify Sonar Report
run: |
echo "Verificando reporte de Sonar..."
Expand Down

0 comments on commit 2de00d5

Please sign in to comment.