asronsr commited on
Commit
e42ca28
·
verified ·
1 Parent(s): 484d7a2

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +803 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Sonarqubeku
3
- emoji: 🏢
4
- colorFrom: gray
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: sonarqubeku
3
+ emoji: 🐳
4
+ colorFrom: yellow
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,803 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>CodeMetrics | Source Code Analysis Tool</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
+ <style>
11
+ .file-drop-area {
12
+ border: 2px dashed #3b82f6;
13
+ border-radius: 0.5rem;
14
+ transition: all 0.3s ease;
15
+ }
16
+ .file-drop-area:hover {
17
+ background-color: rgba(59, 130, 246, 0.1);
18
+ }
19
+ .file-drop-area.active {
20
+ border-color: #10b981;
21
+ background-color: rgba(16, 185, 129, 0.1);
22
+ }
23
+ .metric-card {
24
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
25
+ }
26
+ .metric-card:hover {
27
+ transform: translateY(-5px);
28
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
29
+ }
30
+ .code-block {
31
+ font-family: 'Courier New', Courier, monospace;
32
+ background-color: #1e293b;
33
+ color: #f8fafc;
34
+ border-radius: 0.375rem;
35
+ overflow-x: auto;
36
+ }
37
+ .line-number {
38
+ color: #64748b;
39
+ user-select: none;
40
+ padding-right: 1rem;
41
+ }
42
+ .issue-marker {
43
+ background-color: rgba(239, 68, 68, 0.2);
44
+ border-left: 3px solid #ef4444;
45
+ }
46
+ .nav-link {
47
+ position: relative;
48
+ }
49
+ .nav-link::after {
50
+ content: '';
51
+ position: absolute;
52
+ bottom: -2px;
53
+ left: 0;
54
+ width: 0;
55
+ height: 2px;
56
+ background-color: #3b82f6;
57
+ transition: width 0.3s ease;
58
+ }
59
+ .nav-link:hover::after {
60
+ width: 100%;
61
+ }
62
+ .nav-link.active::after {
63
+ width: 100%;
64
+ }
65
+ </style>
66
+ </head>
67
+ <body class="bg-gray-50 min-h-screen">
68
+ <div class="flex flex-col min-h-screen">
69
+ <!-- Header -->
70
+ <header class="bg-white shadow-sm">
71
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
72
+ <div class="flex justify-between items-center">
73
+ <div class="flex items-center space-x-4">
74
+ <div class="bg-blue-500 text-white p-2 rounded-lg">
75
+ <i class="fas fa-code text-xl"></i>
76
+ </div>
77
+ <h1 class="text-2xl font-bold text-gray-800">CodeMetrics</h1>
78
+ </div>
79
+ <nav class="hidden md:flex space-x-8">
80
+ <a href="#" class="nav-link active text-blue-500 font-medium">Dashboard</a>
81
+ <a href="#" class="nav-link text-gray-600 hover:text-blue-500 font-medium">Projects</a>
82
+ <a href="#" class="nav-link text-gray-600 hover:text-blue-500 font-medium">Issues</a>
83
+ <a href="#" class="nav-link text-gray-600 hover:text-blue-500 font-medium">Rules</a>
84
+ <a href="#" class="nav-link text-gray-600 hover:text-blue-500 font-medium">Quality Gates</a>
85
+ </nav>
86
+ <div class="flex items-center space-x-4">
87
+ <button class="p-2 text-gray-500 hover:text-blue-500">
88
+ <i class="fas fa-bell"></i>
89
+ </button>
90
+ <div class="w-8 h-8 rounded-full bg-blue-500 text-white flex items-center justify-center">
91
+ <span>AD</span>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ </header>
97
+
98
+ <!-- Main Content -->
99
+ <main class="flex-grow max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
100
+ <div class="mb-8">
101
+ <h2 class="text-2xl font-bold text-gray-800 mb-2">Analyze Your Code</h2>
102
+ <p class="text-gray-600">Upload your source code files or connect to a repository to analyze code quality metrics.</p>
103
+ </div>
104
+
105
+ <!-- File Upload Section -->
106
+ <div class="bg-white rounded-xl shadow-sm p-6 mb-8">
107
+ <div id="fileDropArea" class="file-drop-area p-12 text-center cursor-pointer">
108
+ <div class="flex flex-col items-center justify-center space-y-4">
109
+ <div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center text-blue-500">
110
+ <i class="fas fa-cloud-upload-alt text-3xl"></i>
111
+ </div>
112
+ <h3 class="text-lg font-medium text-gray-800">Drag & drop your files here</h3>
113
+ <p class="text-gray-500">or click to browse files</p>
114
+ <input type="file" id="fileInput" class="hidden" multiple accept=".js,.java,.py,.php,.html,.css,.ts,.go,.rb,.cs">
115
+ <button id="browseBtn" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition">
116
+ Browse Files
117
+ </button>
118
+ </div>
119
+ </div>
120
+ <div id="fileList" class="mt-4 hidden">
121
+ <h4 class="font-medium text-gray-700 mb-2">Selected Files:</h4>
122
+ <ul id="selectedFiles" class="space-y-2"></ul>
123
+ </div>
124
+ <div class="mt-6 flex justify-end">
125
+ <button id="analyzeBtn" class="px-6 py-2 bg-green-500 text-white rounded-md hover:bg-green-600 transition disabled:opacity-50 disabled:cursor-not-allowed" disabled>
126
+ <i class="fas fa-play mr-2"></i> Analyze Code
127
+ </button>
128
+ </div>
129
+ </div>
130
+
131
+ <!-- Analysis Results (Initially Hidden) -->
132
+ <div id="analysisResults" class="hidden">
133
+ <!-- Project Overview -->
134
+ <div class="bg-white rounded-xl shadow-sm p-6 mb-8">
135
+ <div class="flex justify-between items-center mb-6">
136
+ <h3 class="text-xl font-bold text-gray-800">Project Analysis Summary</h3>
137
+ <div class="flex space-x-4">
138
+ <button class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">
139
+ <i class="fas fa-download mr-2"></i> Export Report
140
+ </button>
141
+ <button class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
142
+ <i class="fas fa-share-alt mr-2"></i> Share
143
+ </button>
144
+ </div>
145
+ </div>
146
+
147
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
148
+ <!-- Lines of Code -->
149
+ <div class="metric-card bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
150
+ <div class="flex items-center justify-between">
151
+ <div>
152
+ <p class="text-sm font-medium text-gray-500">Lines of Code</p>
153
+ <h3 class="text-2xl font-bold text-gray-800 mt-1" id="locValue">0</h3>
154
+ </div>
155
+ <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center text-blue-500">
156
+ <i class="fas fa-code"></i>
157
+ </div>
158
+ </div>
159
+ <div class="mt-4">
160
+ <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
161
+ <div class="h-full bg-blue-500 rounded-full" style="width: 70%"></div>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <!-- Complexity -->
167
+ <div class="metric-card bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
168
+ <div class="flex items-center justify-between">
169
+ <div>
170
+ <p class="text-sm font-medium text-gray-500">Complexity</p>
171
+ <h3 class="text-2xl font-bold text-gray-800 mt-1" id="complexityValue">0</h3>
172
+ </div>
173
+ <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center text-purple-500">
174
+ <i class="fas fa-project-diagram"></i>
175
+ </div>
176
+ </div>
177
+ <div class="mt-4">
178
+ <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
179
+ <div class="h-full bg-purple-500 rounded-full" style="width: 45%"></div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <!-- Issues -->
185
+ <div class="metric-card bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
186
+ <div class="flex items-center justify-between">
187
+ <div>
188
+ <p class="text-sm font-medium text-gray-500">Issues</p>
189
+ <h3 class="text-2xl font-bold text-gray-800 mt-1" id="issuesValue">0</h3>
190
+ </div>
191
+ <div class="w-12 h-12 bg-red-100 rounded-full flex items-center justify-center text-red-500">
192
+ <i class="fas fa-exclamation-triangle"></i>
193
+ </div>
194
+ </div>
195
+ <div class="mt-4">
196
+ <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
197
+ <div class="h-full bg-red-500 rounded-full" style="width: 30%"></div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+
202
+ <!-- Code Smells -->
203
+ <div class="metric-card bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
204
+ <div class="flex items-center justify-between">
205
+ <div>
206
+ <p class="text-sm font-medium text-gray-500">Code Smells</p>
207
+ <h3 class="text-2xl font-bold text-gray-800 mt-1" id="smellsValue">0</h3>
208
+ </div>
209
+ <div class="w-12 h-12 bg-yellow-100 rounded-full flex items-center justify-center text-yellow-500">
210
+ <i class="fas fa-bug"></i>
211
+ </div>
212
+ </div>
213
+ <div class="mt-4">
214
+ <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
215
+ <div class="h-full bg-yellow-500 rounded-full" style="width: 60%"></div>
216
+ </div>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <!-- Charts -->
222
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
223
+ <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
224
+ <h4 class="font-medium text-gray-700 mb-4">Code Metrics Distribution</h4>
225
+ <canvas id="metricsChart" height="250"></canvas>
226
+ </div>
227
+ <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
228
+ <h4 class="font-medium text-gray-700 mb-4">Issue Severity</h4>
229
+ <canvas id="issuesChart" height="250"></canvas>
230
+ </div>
231
+ </div>
232
+ </div>
233
+
234
+ <!-- File Analysis Details -->
235
+ <div class="bg-white rounded-xl shadow-sm p-6 mb-8">
236
+ <h3 class="text-xl font-bold text-gray-800 mb-6">File Analysis Details</h3>
237
+
238
+ <div class="overflow-x-auto">
239
+ <table class="min-w-full divide-y divide-gray-200">
240
+ <thead class="bg-gray-50">
241
+ <tr>
242
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">File</th>
243
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">LOC</th>
244
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Complexity</th>
245
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Issues</th>
246
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Smells</th>
247
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Coverage</th>
248
+ </tr>
249
+ </thead>
250
+ <tbody id="fileAnalysisTable" class="bg-white divide-y divide-gray-200">
251
+ <!-- Files will be added here dynamically -->
252
+ </tbody>
253
+ </table>
254
+ </div>
255
+ </div>
256
+
257
+ <!-- Code Viewer with Issues -->
258
+ <div class="bg-white rounded-xl shadow-sm p-6">
259
+ <h3 class="text-xl font-bold text-gray-800 mb-6">Code Review</h3>
260
+
261
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
262
+ <!-- File Tree -->
263
+ <div class="lg:col-span-1 bg-gray-50 rounded-lg p-4">
264
+ <h4 class="font-medium text-gray-700 mb-4">Files</h4>
265
+ <div class="space-y-2" id="fileTree">
266
+ <!-- Files will be added here dynamically -->
267
+ </div>
268
+ </div>
269
+
270
+ <!-- Code Viewer -->
271
+ <div class="lg:col-span-2">
272
+ <div class="flex items-center justify-between mb-4">
273
+ <h4 class="font-medium text-gray-700" id="currentFileTitle">Select a file to review</h4>
274
+ <div class="flex space-x-2">
275
+ <button class="p-2 text-gray-500 hover:text-blue-500">
276
+ <i class="fas fa-expand"></i>
277
+ </button>
278
+ <button class="p-2 text-gray-500 hover:text-blue-500">
279
+ <i class="fas fa-copy"></i>
280
+ </button>
281
+ </div>
282
+ </div>
283
+
284
+ <div class="code-block p-4 max-h-96 overflow-y-auto" id="codeViewer">
285
+ <div class="text-center text-gray-500 py-12">
286
+ <i class="fas fa-file-code text-4xl mb-3"></i>
287
+ <p>No file selected</p>
288
+ </div>
289
+ </div>
290
+
291
+ <!-- Issues List -->
292
+ <div class="mt-6">
293
+ <h4 class="font-medium text-gray-700 mb-4">Issues</h4>
294
+ <div class="space-y-3" id="issuesList">
295
+ <div class="text-center text-gray-500 py-8">
296
+ <i class="fas fa-check-circle text-3xl mb-2"></i>
297
+ <p>No issues found for this file</p>
298
+ </div>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </main>
306
+
307
+ <!-- Footer -->
308
+ <footer class="bg-white border-t border-gray-200">
309
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
310
+ <div class="md:flex md:items-center md:justify-between">
311
+ <div class="flex justify-center md:justify-start space-x-6">
312
+ <a href="#" class="text-gray-400 hover:text-gray-500">
313
+ <i class="fab fa-github"></i>
314
+ </a>
315
+ <a href="#" class="text-gray-400 hover:text-gray-500">
316
+ <i class="fab fa-twitter"></i>
317
+ </a>
318
+ <a href="#" class="text-gray-400 hover:text-gray-500">
319
+ <i class="fab fa-linkedin"></i>
320
+ </a>
321
+ </div>
322
+ <div class="mt-4 md:mt-0 text-center md:text-right">
323
+ <p class="text-sm text-gray-500">&copy; 2023 CodeMetrics. All rights reserved.</p>
324
+ </div>
325
+ </div>
326
+ </div>
327
+ </footer>
328
+ </div>
329
+
330
+ <script>
331
+ // DOM Elements
332
+ const fileDropArea = document.getElementById('fileDropArea');
333
+ const fileInput = document.getElementById('fileInput');
334
+ const browseBtn = document.getElementById('browseBtn');
335
+ const fileList = document.getElementById('fileList');
336
+ const selectedFiles = document.getElementById('selectedFiles');
337
+ const analyzeBtn = document.getElementById('analyzeBtn');
338
+ const analysisResults = document.getElementById('analysisResults');
339
+
340
+ // Metrics elements
341
+ const locValue = document.getElementById('locValue');
342
+ const complexityValue = document.getElementById('complexityValue');
343
+ const issuesValue = document.getElementById('issuesValue');
344
+ const smellsValue = document.getElementById('smellsValue');
345
+
346
+ // Table elements
347
+ const fileAnalysisTable = document.getElementById('fileAnalysisTable');
348
+ const fileTree = document.getElementById('fileTree');
349
+ const codeViewer = document.getElementById('codeViewer');
350
+ const currentFileTitle = document.getElementById('currentFileTitle');
351
+ const issuesList = document.getElementById('issuesList');
352
+
353
+ // Sample data for analysis
354
+ const sampleFiles = [
355
+ {
356
+ name: 'app.js',
357
+ loc: 243,
358
+ complexity: 32,
359
+ issues: 5,
360
+ smells: 12,
361
+ coverage: '78%',
362
+ content: `// Main application file
363
+ const express = require('express');
364
+ const app = express();
365
+ const path = require('path');
366
+
367
+ // Configuration
368
+ app.set('view engine', 'ejs');
369
+ app.set('views', path.join(__dirname, 'views'));
370
+
371
+ // Middleware
372
+ app.use(express.json());
373
+ app.use(express.urlencoded({ extended: true }));
374
+ app.use(express.static(path.join(__dirname, 'public')));
375
+
376
+ // Routes
377
+ app.get('/', (req, res) => {
378
+ res.render('index', { title: 'Home' });
379
+ });
380
+
381
+ app.get('/about', (req, res) => {
382
+ res.render('about', { title: 'About' });
383
+ });
384
+
385
+ // Error handling middleware
386
+ app.use((err, req, res, next) => {
387
+ console.error(err.stack);
388
+ res.status(500).send('Something broke!');
389
+ });
390
+
391
+ // Start server
392
+ const PORT = process.env.PORT || 3000;
393
+ app.listen(PORT, () => {
394
+ console.log(\`Server running on port \${PORT}\`);
395
+ });`,
396
+ issues: [
397
+ {
398
+ line: 5,
399
+ severity: 'major',
400
+ message: 'Avoid using path.join with __dirname',
401
+ type: 'security'
402
+ },
403
+ {
404
+ line: 15,
405
+ severity: 'minor',
406
+ message: 'Route handler should be in a separate file',
407
+ type: 'maintainability'
408
+ },
409
+ {
410
+ line: 19,
411
+ severity: 'info',
412
+ message: 'Consider adding input validation',
413
+ type: 'reliability'
414
+ }
415
+ ]
416
+ },
417
+ {
418
+ name: 'utils.js',
419
+ loc: 87,
420
+ complexity: 15,
421
+ issues: 2,
422
+ smells: 4,
423
+ coverage: '92%',
424
+ content: `// Utility functions
425
+ function formatDate(dateString) {
426
+ const date = new Date(dateString);
427
+ return date.toLocaleDateString('en-US', {
428
+ year: 'numeric',
429
+ month: 'long',
430
+ day: 'numeric'
431
+ });
432
+ }
433
+
434
+ function calculateAge(birthDate) {
435
+ const today = new Date();
436
+ const birth = new Date(birthDate);
437
+ let age = today.getFullYear() - birth.getFullYear();
438
+ const monthDiff = today.getMonth() - birth.getMonth();
439
+
440
+ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
441
+ age--;
442
+ }
443
+
444
+ return age;
445
+ }
446
+
447
+ function debounce(func, delay) {
448
+ let timeoutId;
449
+ return function(...args) {
450
+ clearTimeout(timeoutId);
451
+ timeoutId = setTimeout(() => {
452
+ func.apply(this, args);
453
+ }, delay);
454
+ };
455
+ }
456
+
457
+ module.exports = {
458
+ formatDate,
459
+ calculateAge,
460
+ debounce
461
+ };`,
462
+ issues: [
463
+ {
464
+ line: 2,
465
+ severity: 'critical',
466
+ message: 'No validation for invalid date strings',
467
+ type: 'reliability'
468
+ },
469
+ {
470
+ line: 23,
471
+ severity: 'minor',
472
+ message: 'Consider using a library for debounce functionality',
473
+ type: 'maintainability'
474
+ }
475
+ ]
476
+ }
477
+ ];
478
+
479
+ // File handling
480
+ let uploadedFiles = [];
481
+
482
+ // Event Listeners
483
+ browseBtn.addEventListener('click', () => fileInput.click());
484
+
485
+ fileInput.addEventListener('change', handleFileSelect);
486
+
487
+ fileDropArea.addEventListener('dragover', (e) => {
488
+ e.preventDefault();
489
+ fileDropArea.classList.add('active');
490
+ });
491
+
492
+ fileDropArea.addEventListener('dragleave', () => {
493
+ fileDropArea.classList.remove('active');
494
+ });
495
+
496
+ fileDropArea.addEventListener('drop', (e) => {
497
+ e.preventDefault();
498
+ fileDropArea.classList.remove('active');
499
+ fileInput.files = e.dataTransfer.files;
500
+ handleFileSelect({ target: fileInput });
501
+ });
502
+
503
+ analyzeBtn.addEventListener('click', analyzeFiles);
504
+
505
+ // Functions
506
+ function handleFileSelect(e) {
507
+ const files = Array.from(e.target.files);
508
+ if (files.length === 0) return;
509
+
510
+ uploadedFiles = files;
511
+ updateFileList();
512
+ analyzeBtn.disabled = false;
513
+ }
514
+
515
+ function updateFileList() {
516
+ selectedFiles.innerHTML = '';
517
+ uploadedFiles.forEach(file => {
518
+ const li = document.createElement('li');
519
+ li.className = 'flex items-center justify-between bg-gray-50 p-3 rounded-md';
520
+ li.innerHTML = `
521
+ <div class="flex items-center space-x-3">
522
+ <i class="fas fa-file-code text-blue-500"></i>
523
+ <span>${file.name}</span>
524
+ </div>
525
+ <span class="text-sm text-gray-500">${formatFileSize(file.size)}</span>
526
+ `;
527
+ selectedFiles.appendChild(li);
528
+ });
529
+
530
+ fileList.classList.remove('hidden');
531
+ }
532
+
533
+ function formatFileSize(bytes) {
534
+ if (bytes === 0) return '0 Bytes';
535
+ const k = 1024;
536
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
537
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
538
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
539
+ }
540
+
541
+ function analyzeFiles() {
542
+ // Show loading state
543
+ analyzeBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Analyzing...';
544
+ analyzeBtn.disabled = true;
545
+
546
+ // Simulate analysis with timeout
547
+ setTimeout(() => {
548
+ // For demo purposes, we'll use sample data
549
+ displayAnalysisResults(sampleFiles);
550
+
551
+ // Reset button
552
+ analyzeBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Analysis Complete';
553
+
554
+ // Show results
555
+ analysisResults.classList.remove('hidden');
556
+
557
+ // Scroll to results
558
+ analysisResults.scrollIntoView({ behavior: 'smooth' });
559
+ }, 1500);
560
+ }
561
+
562
+ function displayAnalysisResults(files) {
563
+ // Calculate totals
564
+ const totals = {
565
+ loc: files.reduce((sum, file) => sum + file.loc, 0),
566
+ complexity: files.reduce((sum, file) => sum + file.complexity, 0),
567
+ issues: files.reduce((sum, file) => sum + file.issues, 0),
568
+ smells: files.reduce((sum, file) => sum + file.smells, 0)
569
+ };
570
+
571
+ // Update metric cards
572
+ locValue.textContent = totals.loc;
573
+ complexityValue.textContent = totals.complexity;
574
+ issuesValue.textContent = totals.issues;
575
+ smellsValue.textContent = totals.smells;
576
+
577
+ // Create charts
578
+ createMetricsChart(files);
579
+ createIssuesChart(files);
580
+
581
+ // Populate file analysis table
582
+ fileAnalysisTable.innerHTML = '';
583
+ files.forEach(file => {
584
+ const row = document.createElement('tr');
585
+ row.className = 'hover:bg-gray-50 cursor-pointer';
586
+ row.innerHTML = `
587
+ <td class="px-6 py-4 whitespace-nowrap">
588
+ <div class="flex items-center">
589
+ <i class="fas fa-file-code text-blue-500 mr-3"></i>
590
+ <span class="font-medium">${file.name}</span>
591
+ </div>
592
+ </td>
593
+ <td class="px-6 py-4 whitespace-nowrap">${file.loc}</td>
594
+ <td class="px-6 py-4 whitespace-nowrap">${file.complexity}</td>
595
+ <td class="px-6 py-4 whitespace-nowrap">
596
+ <span class="px-2 py-1 text-xs font-medium rounded-full ${file.issues > 5 ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800'}">
597
+ ${file.issues} ${file.issues === 1 ? 'issue' : 'issues'}
598
+ </span>
599
+ </td>
600
+ <td class="px-6 py-4 whitespace-nowrap">${file.smells}</td>
601
+ <td class="px-6 py-4 whitespace-nowrap">
602
+ <div class="flex items-center">
603
+ <div class="w-16 bg-gray-200 rounded-full h-2.5 mr-2">
604
+ <div class="bg-green-500 h-2.5 rounded-full" style="width: ${file.coverage}"></div>
605
+ </div>
606
+ <span>${file.coverage}</span>
607
+ </div>
608
+ </td>
609
+ `;
610
+ fileAnalysisTable.appendChild(row);
611
+
612
+ // Add click event to view file details
613
+ row.addEventListener('click', () => displayFileDetails(file));
614
+ });
615
+
616
+ // Populate file tree
617
+ fileTree.innerHTML = '';
618
+ files.forEach(file => {
619
+ const fileItem = document.createElement('div');
620
+ fileItem.className = 'flex items-center p-2 rounded-md hover:bg-gray-100 cursor-pointer';
621
+ fileItem.innerHTML = `
622
+ <i class="fas fa-file-code text-blue-500 mr-3"></i>
623
+ <span>${file.name}</span>
624
+ `;
625
+ fileItem.addEventListener('click', () => displayFileDetails(file));
626
+ fileTree.appendChild(fileItem);
627
+ });
628
+ }
629
+
630
+ function createMetricsChart(files) {
631
+ const ctx = document.getElementById('metricsChart').getContext('2d');
632
+
633
+ // Extract data for chart
634
+ const labels = files.map(file => file.name);
635
+ const locData = files.map(file => file.loc);
636
+ const complexityData = files.map(file => file.complexity);
637
+ const smellsData = files.map(file => file.smells);
638
+
639
+ new Chart(ctx, {
640
+ type: 'bar',
641
+ data: {
642
+ labels: labels,
643
+ datasets: [
644
+ {
645
+ label: 'Lines of Code',
646
+ data: locData,
647
+ backgroundColor: '#3b82f6',
648
+ borderColor: '#3b82f6',
649
+ borderWidth: 1
650
+ },
651
+ {
652
+ label: 'Complexity',
653
+ data: complexityData,
654
+ backgroundColor: '#8b5cf6',
655
+ borderColor: '#8b5cf6',
656
+ borderWidth: 1
657
+ },
658
+ {
659
+ label: 'Code Smells',
660
+ data: smellsData,
661
+ backgroundColor: '#f59e0b',
662
+ borderColor: '#f59e0b',
663
+ borderWidth: 1
664
+ }
665
+ ]
666
+ },
667
+ options: {
668
+ responsive: true,
669
+ plugins: {
670
+ legend: {
671
+ position: 'top',
672
+ },
673
+ tooltip: {
674
+ mode: 'index',
675
+ intersect: false,
676
+ }
677
+ },
678
+ scales: {
679
+ y: {
680
+ beginAtZero: true
681
+ }
682
+ }
683
+ }
684
+ });
685
+ }
686
+
687
+ function createIssuesChart(files) {
688
+ const ctx = document.getElementById('issuesChart').getContext('2d');
689
+
690
+ // Count issue severities
691
+ let critical = 0, major = 0, minor = 0, info = 0;
692
+
693
+ files.forEach(file => {
694
+ file.issues.forEach(issue => {
695
+ switch(issue.severity) {
696
+ case 'critical': critical++; break;
697
+ case 'major': major++; break;
698
+ case 'minor': minor++; break;
699
+ case 'info': info++; break;
700
+ }
701
+ });
702
+ });
703
+
704
+ new Chart(ctx, {
705
+ type: 'doughnut',
706
+ data: {
707
+ labels: ['Critical', 'Major', 'Minor', 'Info'],
708
+ datasets: [{
709
+ data: [critical, major, minor, info],
710
+ backgroundColor: [
711
+ '#ef4444',
712
+ '#f97316',
713
+ '#f59e0b',
714
+ '#3b82f6'
715
+ ],
716
+ borderWidth: 1
717
+ }]
718
+ },
719
+ options: {
720
+ responsive: true,
721
+ plugins: {
722
+ legend: {
723
+ position: 'right',
724
+ }
725
+ }
726
+ }
727
+ });
728
+ }
729
+
730
+ function displayFileDetails(file) {
731
+ // Update file title
732
+ currentFileTitle.textContent = file.name;
733
+
734
+ // Display code with line numbers and issue markers
735
+ const lines = file.content.split('\n');
736
+ let codeHtml = '<div class="flex flex-col">';
737
+
738
+ lines.forEach((line, index) => {
739
+ const lineNumber = index + 1;
740
+ const hasIssue = file.issues.some(issue => issue.line === lineNumber);
741
+
742
+ codeHtml += `
743
+ <div class="flex ${hasIssue ? 'issue-marker' : ''}">
744
+ <span class="line-number">${lineNumber}</span>
745
+ <span>${escapeHtml(line)}</span>
746
+ </div>
747
+ `;
748
+ });
749
+
750
+ codeHtml += '</div>';
751
+ codeViewer.innerHTML = codeHtml;
752
+
753
+ // Display issues list
754
+ issuesList.innerHTML = '';
755
+
756
+ if (file.issues.length === 0) {
757
+ issuesList.innerHTML = `
758
+ <div class="text-center text-gray-500 py-8">
759
+ <i class="fas fa-check-circle text-3xl mb-2"></i>
760
+ <p>No issues found for this file</p>
761
+ </div>
762
+ `;
763
+ } else {
764
+ file.issues.forEach(issue => {
765
+ const severityColor = {
766
+ 'critical': 'bg-red-100 text-red-800',
767
+ 'major': 'bg-orange-100 text-orange-800',
768
+ 'minor': 'bg-yellow-100 text-yellow-800',
769
+ 'info': 'bg-blue-100 text-blue-800'
770
+ }[issue.severity];
771
+
772
+ const issueItem = document.createElement('div');
773
+ issueItem.className = 'bg-white border border-gray-200 rounded-md p-4';
774
+ issueItem.innerHTML = `
775
+ <div class="flex justify-between items-start">
776
+ <div>
777
+ <span class="px-2 py-1 text-xs font-medium rounded-full ${severityColor} mr-3">
778
+ ${issue.severity.charAt(0).toUpperCase() + issue.severity.slice(1)}
779
+ </span>
780
+ <span class="text-sm font-medium">${issue.type}</span>
781
+ </div>
782
+ <span class="text-sm text-gray-500">Line ${issue.line}</span>
783
+ </div>
784
+ <div class="mt-2 text-sm text-gray-700">
785
+ ${issue.message}
786
+ </div>
787
+ `;
788
+ issuesList.appendChild(issueItem);
789
+ });
790
+ }
791
+ }
792
+
793
+ function escapeHtml(unsafe) {
794
+ return unsafe
795
+ .replace(/&/g, "&amp;")
796
+ .replace(/</g, "&lt;")
797
+ .replace(/>/g, "&gt;")
798
+ .replace(/"/g, "&quot;")
799
+ .replace(/'/g, "&#039;");
800
+ }
801
+ </script>
802
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=asronsr/sonarqubeku" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
803
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ create software analysis like sonarqube. This apps can extract source code to the metric like line of code, complexity, etc