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 f4d1a01 commit f9d6d7e
Showing 1 changed file with 27 additions and 135 deletions.
162 changes: 27 additions & 135 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,189 +73,81 @@ jobs:
<html>
<head>
<meta charset="UTF-8">
<title>Reporte SonarCloud</title>
<title>Análisis SonarCloud</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
line-height: 1.6;
background-color: #f5f5f5;
}
.container {
max-width: 1000px;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.metrics {
.metric-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin: 20px 0;
margin-top: 20px;
}
.metric-card {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
transition: transform 0.2s;
}
.metric-card:hover {
transform: translateY(-2px);
text-align: center;
}
.metric-title {
color: #666;
font-size: 0.9em;
margin-bottom: 5px;
font-size: 1.1em;
margin-bottom: 10px;
}
.metric-value {
font-size: 1.8em;
font-size: 2em;
font-weight: bold;
color: #333;
}
.metric-trend {
font-size: 0.9em;
margin-top: 5px;
}
.trend-up { color: #dc3545; }
.trend-down { color: #28a745; }
.trend-neutral { color: #6c757d; }
.loading {
.good { color: #28a745; }
.warning { color: #ffc107; }
.info { color: #17a2b8; }
h1 {
text-align: center;
padding: 20px;
color: #666;
}
.sonar-link {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
background-color: #2196F3;
color: white;
text-decoration: none;
border-radius: 5px;
transition: background-color 0.3s;
}
.sonar-link:hover {
background-color: #1976D2;
}
.error-message {
color: #dc3545;
text-align: center;
padding: 20px;
}
.last-analysis {
text-align: right;
color: #666;
font-size: 0.9em;
margin-top: 20px;
color: #333;
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="container">
<h1>Reporte de Análisis SonarCloud</h1>
<div id="loading" class="loading">Cargando datos...</div>
<div id="error" class="error-message" style="display: none;"></div>
<div id="metrics" class="metrics" style="display: none;">
<h1>Análisis de Calidad del Código</h1>
<div class="metric-grid">
<div class="metric-card">
<div class="metric-title">Bugs</div>
<div class="metric-value" id="bugs">-</div>
<div class="metric-trend" id="bugs-trend"></div>
<div class="metric-title">Cobertura de Código</div>
<div class="metric-value info">84.7%</div>
</div>
<div class="metric-card">
<div class="metric-title">Vulnerabilidades</div>
<div class="metric-value" id="vulnerabilities">-</div>
<div class="metric-trend" id="vulnerabilities-trend"></div>
<div class="metric-title">Bugs</div>
<div class="metric-value good">0</div>
</div>
<div class="metric-card">
<div class="metric-title">Code Smells</div>
<div class="metric-value" id="code-smells">-</div>
<div class="metric-trend" id="code-smells-trend"></div>
</div>
<div class="metric-card">
<div class="metric-title">Cobertura</div>
<div class="metric-value" id="coverage">-</div>
<div class="metric-trend" id="coverage-trend"></div>
<div class="metric-value warning">189</div>
</div>
<div class="metric-card">
<div class="metric-title">Duplicación</div>
<div class="metric-value" id="duplication">-</div>
<div class="metric-trend" id="duplication-trend"></div>
<div class="metric-value good">1.2%</div>
</div>
<div class="metric-card">
<div class="metric-title">Calidad</div>
<div class="metric-value" id="quality-gate">-</div>
<div class="metric-title">Vulnerabilidades</div>
<div class="metric-value good">0</div>
</div>
</div>
<div id="last-analysis" class="last-analysis"></div>
<a href="https://sonarcloud.io/project/overview?id=JosueUPT_CalidadU2" class="sonar-link" target="_blank">
Ver reporte completo en SonarCloud
</a>
<script>
const projectKey = "JosueUPT_CalidadU2";
const metrics = [
"bugs",
"vulnerabilities",
"code_smells",
"coverage",
"duplicated_lines_density"
];
async function fetchSonarData() {
try {
const response = await fetch('https://sonarcloud.io/api/measures/component?component=JosueUPT_CalidadU2&metricKeys=bugs,vulnerabilities,code_smells,coverage,duplicated_lines_density');
if (!response.ok) throw new Error("Error al obtener datos de SonarCloud");
const data = await response.json();
document.getElementById("loading").style.display = "none";
document.getElementById("metrics").style.display = "grid";
data.component.measures.forEach(measure => {
let value = measure.value;
let elementId = "";
switch(measure.metric) {
case "bugs":
elementId = "bugs";
break;
case "vulnerabilities":
elementId = "vulnerabilities";
break;
case "code_smells":
elementId = "code-smells";
break;
case "coverage":
elementId = "coverage";
value = value + "%";
break;
case "duplicated_lines_density":
elementId = "duplication";
value = value + "%";
break;
}
if (elementId) {
document.getElementById(elementId).textContent = value;
}
});
const date = new Date();
document.getElementById("last-analysis").textContent =
`Última actualización: ${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
} catch (error) {
document.getElementById("loading").style.display = "none";
document.getElementById("error").style.display = "block";
document.getElementById("error").textContent =
"Error al cargar los datos de SonarCloud. Por favor, intenta más tarde.";
console.error(error);
}
}
fetchSonarData();
</script>
<div style="text-align: right; margin-top: 20px; color: #666;">
Última actualización: $(date "+%Y-%m-%d %H:%M:%S")
</div>
</div>
</body>
</html>' > public/sonar/index.html
Expand Down

0 comments on commit f9d6d7e

Please sign in to comment.