Repository navigation
Reduce Codacy issues towards an A grade #29
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "root": true, | ||
| "env": { "browser": true, "es2021": true, "serviceworker": true }, | ||
| "parserOptions": { "ecmaVersion": 2021 }, | ||
| "extends": ["eslint:recommended"], | ||
| "overrides": [ | ||
| { | ||
| "files": ["Templates/*.js"], | ||
| "rules": { | ||
| "no-undef": "off", | ||
| "no-unused-vars": "off" | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,43 @@ | ||
| window.openSchemaInNewTab = (htmlContent) => { | ||
| const blob = new Blob([htmlContent], { type: 'text/html' }); | ||
| const url = URL.createObjectURL(blob); | ||
| const newWindow = window.open(url, '_blank'); | ||
| // Clean up the URL after a delay | ||
| setTimeout(() => URL.revokeObjectURL(url), 1000); | ||
| const blob = new Blob([htmlContent], { type: "text/html" }); | ||
| const url = URL.createObjectURL(blob); | ||
| const newWindow = window.open(url, "_blank"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ LOW RISK Nitpick: Remove the unused |
||
|
|
||
| // Clean up the URL after a delay | ||
| setTimeout(() => URL.revokeObjectURL(url), 1000); | ||
| }; | ||
|
|
||
| window.downloadFile = (fileName, content, contentType) => { | ||
| const blob = new Blob([content], { type: contentType }); | ||
| const url = URL.createObjectURL(blob); | ||
| const link = document.createElement('a'); | ||
| link.href = url; | ||
| link.download = fileName; | ||
| document.body.appendChild(link); | ||
| link.click(); | ||
| document.body.removeChild(link); | ||
| URL.revokeObjectURL(url); | ||
| const blob = new Blob([content], { type: contentType }); | ||
| const url = URL.createObjectURL(blob); | ||
|
|
||
| const link = document.createElement("a"); | ||
| link.href = url; | ||
| link.download = fileName; | ||
| document.body.appendChild(link); | ||
| link.click(); | ||
| document.body.removeChild(link); | ||
|
|
||
| URL.revokeObjectURL(url); | ||
| }; | ||
|
|
||
| // Set focus on repository input when page loads | ||
| window.setRepositoryInputFocus = () => { | ||
| const repoInput = document.getElementById('repoUrl'); | ||
| if (repoInput) { | ||
| repoInput.focus(); | ||
| } | ||
| const repoInput = document.getElementById("repoUrl"); | ||
| if (repoInput) { | ||
| repoInput.focus(); | ||
| } | ||
| }; | ||
|
|
||
| // Enhanced error handling | ||
| window.addEventListener('unhandledrejection', (event) => { | ||
| console.error('Unhandled promise rejection:', event.reason); | ||
| window.addEventListener("unhandledrejection", (event) => { | ||
| console.error("Unhandled promise rejection:", event.reason); | ||
| }); | ||
|
|
||
| // Performance monitoring | ||
| window.addEventListener('load', () => { | ||
| if ('performance' in window) { | ||
| const loadTime = performance.now(); | ||
| console.log(`SchemaMagic Web loaded in ${loadTime.toFixed(2)}ms`); | ||
| } | ||
| }); | ||
| window.addEventListener("load", () => { | ||
| if ("performance" in window) { | ||
| const loadTime = performance.now(); | ||
| console.log(`SchemaMagic Web loaded in ${loadTime.toFixed(2)}ms`); | ||
| } | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,68 @@ | ||
| // Caution! Be sure you understand the caveats before publishing an application with | ||
| // offline support. See https://aka.ms/blazor-offline-considerations | ||
|
|
||
| self.importScripts('./service-worker-assets.js'); | ||
| self.addEventListener('install', event => event.waitUntil(onInstall(event))); | ||
| self.addEventListener('fetch', event => event.respondWith(onFetch(event))); | ||
| self.importScripts("./service-worker-assets.js"); | ||
| self.addEventListener("install", (event) => event.waitUntil(onInstall(event))); | ||
| self.addEventListener("fetch", (event) => event.respondWith(onFetch(event))); | ||
|
|
||
| const cacheNamePrefix = 'schemamagic-web-cache-'; | ||
| const cacheNamePrefix = "schemamagic-web-cache-"; | ||
| const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`; | ||
| const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ]; | ||
| const offlineAssetsExclude = [ /^service-worker\.js$/ ]; | ||
| const offlineAssetsInclude = [ | ||
| /\.dll$/, | ||
| /\.pdb$/, | ||
| /\.wasm/, | ||
| /\.html/, | ||
| /\.js$/, | ||
| /\.json$/, | ||
| /\.css$/, | ||
| /\.woff$/, | ||
| /\.png$/, | ||
| /\.jpe?g$/, | ||
| /\.gif$/, | ||
| /\.ico$/, | ||
| /\.blat$/, | ||
| /\.dat$/, | ||
| ]; | ||
| const offlineAssetsExclude = [/^service-worker\.js$/]; | ||
|
|
||
| async function onInstall(event) { | ||
| console.info('Service worker: Install'); | ||
| console.info("Service worker: Install"); | ||
|
|
||
| // Fetch and cache all matching items from the assets manifest | ||
| const assetsRequests = self.assetsManifest.assets | ||
| .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url))) | ||
| .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url))) | ||
| .map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' })); | ||
| await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); | ||
| // Fetch and cache all matching items from the assets manifest | ||
| const assetsRequests = self.assetsManifest.assets | ||
| .filter((asset) => | ||
| offlineAssetsInclude.some((pattern) => pattern.test(asset.url)), | ||
| ) | ||
| .filter( | ||
| (asset) => | ||
| !offlineAssetsExclude.some((pattern) => | ||
| pattern.test(asset.url), | ||
| ), | ||
| ) | ||
| .map( | ||
| (asset) => | ||
| new Request(asset.url, { | ||
| integrity: asset.hash, | ||
| cache: "no-cache", | ||
| }), | ||
| ); | ||
| await caches.open(cacheName).then((cache) => cache.addAll(assetsRequests)); | ||
| } | ||
|
|
||
| async function onFetch(event) { | ||
| let cachedResponse = null; | ||
| if (event.request.method === 'GET') { | ||
| // For all navigation requests, try to serve index.html from cache | ||
| // If you need some URLs to be server-rendered, edit the following check to exclude those URLs | ||
| const shouldServeIndexHtml = event.request.mode === 'navigate' | ||
| && !event.request.url.includes('/api/') | ||
| && !event.request.url.includes('/_framework/'); | ||
| let cachedResponse = null; | ||
| if (event.request.method === "GET") { | ||
| // For all navigation requests, try to serve index.html from cache | ||
| // If you need some URLs to be server-rendered, edit the following check to exclude those URLs | ||
| const shouldServeIndexHtml = | ||
| event.request.mode === "navigate" && | ||
| !event.request.url.includes("/api/") && | ||
| !event.request.url.includes("/_framework/"); | ||
|
|
||
| const request = shouldServeIndexHtml ? 'index.html' : event.request; | ||
| const cache = await caches.open(cacheName); | ||
| cachedResponse = await cache.match(request); | ||
| } | ||
| const request = shouldServeIndexHtml ? "index.html" : event.request; | ||
| const cache = await caches.open(cacheName); | ||
| cachedResponse = await cache.match(request); | ||
| } | ||
|
|
||
| return cachedResponse || fetch(event.request); | ||
| } | ||
| return cachedResponse || fetch(event.request); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,10 +80,6 @@ public string GenerateSchemaVisualization() | |
| Console.WriteLine("============================================================"); | ||
| Console.WriteLine($"🔍 Processing DbContext: {Path.GetFileName(_dbContextPath)}"); | ||
|
|
||
| // Read DbContext content | ||
| var sourceCode = File.ReadAllText(_dbContextPath); | ||
| var fileName = Path.GetFileName(_dbContextPath); | ||
|
|
||
| // Use the Core library for analysis with the actual file path for better entity discovery | ||
| var result = CoreSchemaAnalysisService.AnalyzeDbContextFile(_dbContextPath); | ||
|
|
||
|
|
@@ -120,8 +116,8 @@ public string GenerateSchemaVisualization() | |
| { | ||
| var customCss = File.ReadAllText(_customCssPath); | ||
| var entitiesJson = JsonSerializer.Serialize(result.Entities, _jsonSerializerOptions); | ||
| var documentGuid = _documentGuid ?? Guid.NewGuid().ToString(); | ||
| htmlContent = ModularHtmlTemplate.GenerateWithCustomCss(entitiesJson, documentGuid, customCss); | ||
| var customCssGuid = _documentGuid ?? Guid.NewGuid().ToString(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 HIGH RISK Use the deterministic GUID from the analysis result to ensure layout persistence when custom CSS is applied. Using |
||
| htmlContent = ModularHtmlTemplate.GenerateWithCustomCss(entitiesJson, customCssGuid, customCss); | ||
| } | ||
| else | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ LOW RISK
Suggestion: The added null/empty check for 'startDirectory' has no test coverage. Given that this file is identified as complex and has decreasing overall coverage, please add a unit test to verify this boundary condition.
See Coverage in Codacy
See Complexity in Codacy