🚨 Fixed DeepSource issues

This commit is contained in:
Mawoka
2023-06-14 16:33:44 +02:00
parent 6673a77b8a
commit db26082a00
28 changed files with 47 additions and 68 deletions
@@ -4,6 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
// Stolen from https://svelte.dev/repl/c6a402704224403f96a3db56c2f48dfc?version=3.55.0
// skipcq: JS-0119
let intersectionObserver;
function ensureIntersectionObserver() {
+2
View File
@@ -42,10 +42,12 @@ export const mint = async (
// eslint-disable-next-line no-constant-condition
while (true) {
// skipcq: JS-0003
const data = new TextEncoder().encode(`${challenge}:${counter.toString(16)}`);
const hashBuffer = await crypto.subtle.digest('SHA-1', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const digest = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
// skipcq: JS-0050
if (digest.slice(0, hex_digits) == zeros) {
result = counter.toString(16);
break;
+10 -9
View File
@@ -10,8 +10,8 @@ export const invertColor = (hexTripletColor: string): string => {
let color_int = parseInt(color, 16); // convert to integer
color_int = 0xffffff ^ color_int; // invert three bytes
color = color_int.toString(16); // convert to hex
color = ('000000' + color).slice(-6); // pad with leading zeros
color = '#' + color; // prepend #
color = `000000${color}`.slice(-6); // pad with leading zeros
color = `#${color}`; // prepend #
return color;
};
@@ -20,13 +20,6 @@ export const calculate_score = (q_time: number, time_taken: number): number => {
};
export type RGB = [number, number, number];
export const getContrast = (foregroundColor: RGB, backgroundColor: RGB) => {
const foregroundLuminance = getLuminance(foregroundColor);
const backgroundLuminance = getLuminance(backgroundColor);
return backgroundLuminance < foregroundLuminance
? (backgroundLuminance + 0.05) / (foregroundLuminance + 0.05)
: (foregroundLuminance + 0.05) / (backgroundLuminance + 0.05);
};
export const getLuminance = (rgb: RGB): number => {
const [r, g, b] = rgb.map((v) => {
@@ -36,6 +29,14 @@ export const getLuminance = (rgb: RGB): number => {
return r * 0.2126 + g * 0.7152 + b * 0.0722;
};
export const getContrast = (foregroundColor: RGB, backgroundColor: RGB) => {
const foregroundLuminance = getLuminance(foregroundColor);
const backgroundLuminance = getLuminance(backgroundColor);
return backgroundLuminance < foregroundLuminance
? (backgroundLuminance + 0.05) / (foregroundLuminance + 0.05)
: (foregroundLuminance + 0.05) / (backgroundLuminance + 0.05);
};
export const getRgbColorFromHex = (hex: string): RGB => {
hex = hex.slice(1);
const value = parseInt(hex, 16);
+1 -6
View File
@@ -4,6 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
// skipcq: JS-C1003
import * as yup from 'yup';
export const ABCDQuestionSchema = yup
@@ -69,23 +70,17 @@ export const dataSchema = yup.object({
answers: yup.lazy((v) => {
if (Array.isArray(v)) {
if (typeof v[0].right === 'boolean') {
console.log('ABCDQuestionSchema');
return ABCDQuestionSchema;
} else if (typeof v[0].case_sensitive === 'boolean') {
console.log('TextQuestionSchema');
return TextQuestionSchema;
} else if (v[0].id !== undefined) {
console.log('OrderQuestionSchema');
return VotingQuestionSchema;
} else if (v[0].answer !== undefined) {
console.log('VotingQuestionSchema');
return VotingQuestionSchema;
}
} else if (typeof v === 'string' || v instanceof String) {
console.log('StringQuestionSchema');
return yup.string().required("The slide mustn't be empty").nullable();
} else {
console.log('RangeQuestionSchema');
return RangeQuestionSchema;
}
})
+1 -3
View File
@@ -7,7 +7,5 @@ import type { PageLoad } from './$types';
export const load = (async ({ fetch }) => {
const res = await fetch('/api/v1/storage/list');
if (res.ok) {
return { files: await res.json() };
}
return { files: await res.json() };
}) satisfies PageLoad;