Codacy var names part 2

This commit is contained in:
Matteo Gheza 2021-04-05 19:13:40 +02:00
parent 6f62fdeddf
commit 3c40f31c05
16 changed files with 89 additions and 89 deletions

View File

@ -75,7 +75,7 @@ foreach ($remotes as $key => $value) {
$config[$key]["before"] = [];
} else {
$env = isset($config[$key]["sentry_env"]) ? $config[$key]["sentry_env"] : "prod";
$config[$key]["before"][] = "local: cd server/resources && npm i && npm run prod -- --env sentry_environment=".$env;
$config[$key]["before"][] = "local: cd server/resources && npm i && npm run prod -- --env sentryEnvironment=".$env;
}
if(isset($value["after"]) && $value["after"] === false){
$config[$key]["after"] = [];

View File

@ -1,8 +1,8 @@
{
"sentry_enabled": false,
"sentry_dsn": "",
"sentry_environment": "prod",
"sentry_auth_token": "",
"sentry_organization": "",
"sentry_project": ""
"sentryEnabled": false,
"sentryDsn": "",
"sentryEnvironment": "prod",
"sentryAuthToken": "",
"sentryOrganization": "",
"sentryProject": ""
}

View File

@ -8,7 +8,7 @@ async function play (game) {
const game = new Game();
$("body").append("<div class=\"modal\" id=\"modal_game\" tabindex=\"-1\" role=\"dialog\" data-backdrop=\"static\" style=\"display: none; min-width: 100%; margin: 0px;\"><div class=\"modal-dialog\" role=\"document\" style=\"min-width: 100%; margin: 0;\"><div class=\"modal-content\" style=\"min-height: 100vh;\" id=\"modal_game_content\"></div></div></div>");
$("#modal_game_content").append(`<div class="modal-header"><h5 class="modal-title" style="color: black">${game.title}</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body" id="modal_game_body"></div>`);
$("#modal_game_body").append(`<div id="game_content" style="text-align: center"></div><p style="text-align: right; color: black;">Game by <a style="color: blue" target="_blank" href="${game.author_url}">${game.author}</a></p>`);
$("#modal_game_body").append(`<div id="game_content" style="text-align: center"></div><p style="text-align: right; color: black;">Game by <a style="color: blue" target="_blank" href="${game.authorUrl}">${game.author}</a></p>`);
$("#modal_game").modal("show");
game.initialize($("#game_content"));
});

View File

@ -2,7 +2,7 @@ export default class {
constructor(){
this.title = "Empty game";
this.author = "Prova";
this.author_url = "https://example.com/";
this.authorUrl = "https://example.com/";
}
initialize(container){

View File

@ -2,17 +2,17 @@ import {default as createUnityInstance} from './ld46.loader.js';
import build_size_data from './ld46.data.gz';
import buildSizeFramework from './ld46.framework.js.gz';
import build_size_wasm from './ld46.wasm.gz';
import buildSizeWasm from './ld46.wasm.gz';
console.log("data "+build_size_data);
console.log("framework "+buildSizeFramework);
console.log("wasm "+build_size_wasm);
console.log("wasm "+buildSizeWasm);
export default class {
constructor(){
this.title = "What the firetruck";
this.author = "dvdfu";
this.author_url = "https://github.com/dvdfu";
this.authorUrl = "https://github.com/dvdfu";
}
initialize(container){

View File

@ -150,10 +150,10 @@ var oldData = "null";
var tableEngine = "datatables";
var fillTable = undefined;
async function loadTable ({ tablePage, set_interval = true, interval = 10000, onlineReload = false, use_custom_tableEngine = false, callback = false }) {
async function loadTable ({ tablePage, setInterval = true, interval = 10000, onlineReload = false, useCustomTableEngine = false, callback = false }) {
if (typeof fillTable === "undefined") {
if (use_custom_tableEngine !== false) {
tableEngine = use_custom_tableEngine;
if (useCustomTableEngine !== false) {
tableEngine = useCustomTableEngine;
} else if ("connection" in navigator && navigator.connection.saveData) {
tableEngine = "default";
}
@ -200,7 +200,7 @@ async function loadTable ({ tablePage, set_interval = true, interval = 10000, on
}).fail(function (data, status) {
if (status === "parsererror") {
if ($("#table_body").children().length === 0) { // this is a server-side authentication error on some cheap hosting providers
loadTable(tablePage, set_interval, interval); // retry
loadTable(tablePage, setInterval, interval); // retry
} // else nothing
} else {
caches.open("tables-1").then(cache => {
@ -218,13 +218,13 @@ async function loadTable ({ tablePage, set_interval = true, interval = 10000, on
}
}
});
if (set_interval) {
if (setInterval) {
if ("connection" in navigator && navigator.connection.saveData) {
interval += 5000;
}
console.log("table_load interval " + interval);
window.loadTableInterval = setInterval(function () {
window.loadTable({ tablePage, set_interval: false, interval, onlineReload, use_custom_tableEngine, callback: false });
window.loadTable({ tablePage, setInterval: false, interval, onlineReload, useCustomTableEngine, callback: false });
}, interval);
}
}

View File

@ -22,7 +22,7 @@ let marker;
let feature;
let map;
function set_marker (LatLng) {
function setMarker (LatLng) {
if (marker) {
console.log("Marker exists");
// console.log(marker);
@ -35,17 +35,17 @@ function set_marker (LatLng) {
marker = L.marker(LatLng, { icon: iconDefault }).addTo(map);
}
function load_map (lat = undefined, lng = undefined, selector_id = undefined, select = true) {
function loadMap (lat = undefined, lng = undefined, selectorId = undefined, select = true) {
if (lat === undefined && lng === undefined) {
lat = 45.5285; // TODO: replace hard-coded into cookie reading
lng = 10.2956;
}
if (selector_id === undefined) {
selector_id = "map";
if (selectorId === undefined) {
selectorId = "map";
}
const zoom = select ? 10 : 17;
const latLng = new L.LatLng(lat, lng);
map = new L.Map(selector_id, { zoomControl: true });
map = new L.Map(selectorId, { zoomControl: true });
const osmUrl = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
const osmAttribution = "Map data &copy; 2012 <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors";
@ -55,12 +55,12 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se
if (select) {
map.on("click", function (e) {
set_marker(e.latlng);
setMarker(e.latlng);
});
L.Control.CustomLocate = L.Control.Locate.extend({
_drawMarker: function () {
set_marker(this._event.latlng);
setMarker(this._event.latlng);
},
_onDrag: function () {},
_onZoom: function () {},
@ -87,7 +87,7 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se
console.log("Loading location from clipboard");
navigator.clipboard.readText().then(text => {
$("#addr").val(text);
if (!addr_search()) {
if (!addrSearch()) {
$("#addr").val("");
}
}).catch(err => {
@ -97,25 +97,25 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se
});
}
} else {
set_marker(latLng);
setMarker(latLng);
}
map.invalidateSize();
}
// from unknown source in the Internet
function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 = undefined, lat2 = undefined, lng2 = undefined, osm_type = undefined) {
function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 = undefined, lat2 = undefined, lng2 = undefined, osmType = undefined) {
addrLat = addrLat.replace(",", ".");
addrLng = addrLng.replace(",", ".");
if (lat1 !== undefined && lng1 !== undefined && lat2 !== undefined && lng2 !== undefined && osm_type !== undefined) {
if (lat1 !== undefined && lng1 !== undefined && lat2 !== undefined && lng2 !== undefined && osmType !== undefined) {
const loc1 = new L.LatLng(lat1, lng1);
const loc2 = new L.LatLng(lat2, lng2);
const bounds = new L.LatLngBounds(loc1, loc2);
console.log(lat1, lng1, lat2, lng2, osm_type);
set_marker(new L.LatLng(addrLat, addrLng));
console.log(lat1, lng1, lat2, lng2, osmType);
setMarker(new L.LatLng(addrLat, addrLng));
if (feature) {
map.removeLayer(feature);
}
if (osm_type === "node") {
if (osmType === "node") {
map.fitBounds(bounds);
map.setZoom(18);
} else {
@ -127,7 +127,7 @@ function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1
} else if (addrLat !== undefined && addrLng !== undefined) {
const loc = new L.LatLng(addrLat, addrLng);
console.log(loc);
set_marker(loc);
setMarker(loc);
if (zoom !== undefined) {
map.setView(loc, zoom);
} else {
@ -137,17 +137,17 @@ function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1
}
// started from https://derickrethans.nl/leaflet-and-nominatim.html
function addr_search (string_results_found = undefined, string_results_not_found = undefined) {
function addrSearch (string_results_found = undefined, stringResultsNotFound = undefined) {
function searchError (error, checkClipboard) {
if (!checkClipboard) {
$("<p>", { html: string_results_not_found }).appendTo("#results");
$("<p>", { html: stringResultsNotFound }).appendTo("#results");
console.error(error);
}
return false;
}
let inp = document.getElementById("addr").value;
// if translation strings are not defined, skip the nominatim step and don't log errors (no console.error)
const checkClipboard = string_results_found === undefined && string_results_not_found === undefined;
const checkClipboard = string_results_found === undefined && stringResultsNotFound === undefined;
$("#results").empty();
if (inp.match("\@(-?[\d\.]*)")) { // Google Maps
@ -197,7 +197,7 @@ function addr_search (string_results_found = undefined, string_results_not_found
html: items.join("")
}).appendTo("#results");
} else {
$("<p>", { html: string_results_not_found }).appendTo("#results");
$("<p>", { html: stringResultsNotFound }).appendTo("#results");
}
});
} else {
@ -205,6 +205,6 @@ function addr_search (string_results_found = undefined, string_results_not_found
}
}
window.load_map = load_map;
window.addr_search = addr_search;
window.loadMap = loadMap;
window.addrSearch = addrSearch;
window.chooseAddr = chooseAddr;

View File

@ -1,16 +1,16 @@
import * as Sentry from "@sentry/browser";
import { Integrations } from "@sentry/tracing";
if (process.env.config && process.env.config.sentry_enabled) {
if (process.env.config && process.env.config.sentryEnabled) {
if ("connection" in navigator && navigator.connection.saveData) {
console.log("Skipping Sentry init because data save is enabled");
} else {
Sentry.init({
dsn: process.env.config.sentry_dsn,
dsn: process.env.config.sentryDsn,
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 0.6,
release: "allerta-vvf-frontend@" + process.env.GIT_VERSION,
environment: process.env.config.sentry_environment
environment: process.env.config.sentryEnvironment
});
}
}

View File

@ -4,7 +4,7 @@ const expectedCaches = [cacheName, "tables-1"];
const urls = ["offline.php", "manifest.webmanifest", "resources/images/favicon.ico", "resources/dist/marker-icon.png", "resources/dist/layers.png", "resources/dist/layers-2x.png", "resources/images/android-chrome-192x192.png", "resources/images/android-chrome-384x384.png", "resources/images/black_helmet.png", "resources/images/red_helmet.png", "resources/images/wheel.png", "resources/images/logo.png", "resources/images/owner.png", "resources/dist/fonts/fontawesome-webfont.woff2"];
function fetchHandler (event, content_type, not_found_message) {
function fetchHandler (event, contentType, notFoundMessage) {
// TODO: refactoring
console.log(event);
@ -79,10 +79,10 @@ self.addEventListener("install", (event) => {
.then((response) => response.json())
.then((manifest) => {
const scripts_required = ["main.js", "maps.js"];
scripts_required.map((script_name) => {
scripts_required.map((scriptName) => {
console.log(manifest);
console.log(script_name);
cache.add("resources/dist/" + manifest[script_name]);
console.log(scriptName);
cache.add("resources/dist/" + manifest[scriptName]);
});
});
})

View File

@ -15,9 +15,9 @@ pdfMake.vfs = pdfFonts.pdfMake.vfs;
export default async function fillTable ({ data, replaceLatLngWithMap = false, callback = false }) {
$("#table_body").empty();
$.each(data, function (row_num, item) {
$.each(data, function (rowNum, item) {
const row = document.createElement("tr");
row.id = "row-" + row_num;
row.id = "row-" + rowNum;
$.each(item, function (cell_num, i) {
if (i !== null) {
if (replaceLatLngWithMap && i.match(/[+-]?\d+([.]\d+)?[;][+-]?\d+([.]\d+)?/gm)) { /* credits to @visoom https://github.com/visoom */
@ -25,9 +25,9 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c
const lng = i.split(";")[1];
const mapDiv = document.createElement("div");
mapDiv.className = "map";
mapDiv.id = "map-" + row_num;
mapDiv.id = "map-" + rowNum;
const mapScript = document.createElement("script");
mapScript.appendChild(document.createTextNode("load_map(" + lat + ", " + lng + ", \"map-" + row_num + "\", false)"));
mapScript.appendChild(document.createTextNode("loadMap(" + lat + ", " + lng + ", \"map-" + rowNum + "\", false)"));
mapDiv.appendChild(mapScript);
const cell = document.createElement("td");
cell.appendChild(mapDiv);
@ -56,19 +56,19 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c
loadedLanguage = {};
}
if (!$.fn.DataTable.isDataTable("#table")) {
var table_dt = $("#table").DataTable({
var setableDt = $("#table").DataTable({
responsive: true,
language: loadedLanguage,
buttons: ["excel", "pdf", "csv"]
});
table_dt.buttons().container()
setableDt.buttons().container()
.appendTo("#table_wrapper :nth-child(1):eq(0)");
if (callback !== false) {
callback(table_dt);
callback(setableDt);
}
} else {
table_dt.rows().invalidate();
setableDt.rows().invalidate();
}
window.table_dt = table_dt;
window.setableDt = setableDt;
}

View File

@ -1,8 +1,8 @@
export default async function fillTable ({ data, replaceLatLngWithMap = false, callback = false }) {
$("#table_body").empty();
$.each(data, function (row_num, item) {
$.each(data, function (rowNum, item) {
const row = document.createElement("tr");
row.id = "row-" + row_num;
row.id = "row-" + rowNum;
$.each(item, function (cell_num, i) {
if (i !== null) {
if (replaceLatLngWithMap && i.match(/[+-]?\d+([.]\d+)?[;][+-]?\d+([.]\d+)?/gm)) { /* credits to @visoom https://github.com/visoom */
@ -10,9 +10,9 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c
const lng = i.split(";")[1];
const mapDiv = document.createElement("div");
mapDiv.className = "map";
mapDiv.id = "map-" + row_num;
mapDiv.id = "map-" + rowNum;
const mapScript = document.createElement("script");
mapScript.appendChild(document.createTextNode("load_map(" + lat + ", " + lng + ", \"map-" + row_num + "\", false)"));
mapScript.appendChild(document.createTextNode("loadMap(" + lat + ", " + lng + ", \"map-" + rowNum + "\", false)"));
mapDiv.appendChild(mapScript);
const cell = document.createElement("td");
cell.appendChild(mapDiv);

View File

@ -3,14 +3,14 @@ const common = require("./webpack.common.js");
const TerserPlugin = require("terser-webpack-plugin");
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const AfterBuildPlugin = require("@fiverr/afterbuild-webpack-plugin");
const child_process = require("child_process");
const childProcess = require("childProcess");
const InjectPlugin = require("webpack-inject-plugin").default;
const colors = require("colors/safe");
const fs = require("fs");
const glob = require("glob");
function git(command) {
return child_process.execSync(`git ${command}`, { encoding: "utf8" }).trim();
return childProcess.execSync(`git ${command}`, { encoding: "utf8" }).trim();
}
var webpack = require("webpack");
@ -45,12 +45,12 @@ const removeSourceMapUrlAfterBuild = () => {
}
var configFile = require("./config.json");
const sentry_enabled = configFile.sentry_enabled &&
configFile.sentry_auth_token &&
configFile.sentry_organization &&
configFile.sentry_project;
const sentryEnabled = configFile.sentryEnabled &&
configFile.sentryAuthToken &&
configFile.sentryOrganization &&
configFile.sentryProject;
var prod_config = {
var prodConfig = {
mode: "production",
devtool: false,
module: {
@ -75,31 +75,31 @@ var prod_config = {
minimizer: [new TerserPlugin({
parallel: true,
extractComments: true,
sourceMap: sentry_enabled ? true : false
sourceMap: sentryEnabled ? true : false
})]
}
};
module.exports = (env) => {
//run webpack build with "--env sentry_environment=custom-sentry-env" to replace Sentry environment
if(env.sentry_environment){
console.log(colors.green("INFO using custom sentry_environment "+env.sentry_environment));
configFile.sentry_environment = env.sentry_environment;
//run webpack build with "--env sentryEnvironment=custom-sentry-env" to replace Sentry environment
if(env.sentryEnvironment){
console.log(colors.green("INFO using custom sentryEnvironment "+env.sentryEnvironment));
configFile.sentryEnvironment = env.sentryEnvironment;
}
if(!configFile.sentry_environment){
configFile.sentry_environment = "prod";
if(!configFile.sentryEnvironment){
configFile.sentryEnvironment = "prod";
}
if(sentry_enabled){
prod_config.plugins.push(
if(sentryEnabled){
prodConfig.plugins.push(
new webpack.SourceMapDevToolPlugin({
filename: "[file].map"
}),
new SentryWebpackPlugin({
authToken: configFile.sentry_auth_token,
org: configFile.sentry_organization,
project: configFile.sentry_project,
authToken: configFile.sentryAuthToken,
org: configFile.sentryOrganization,
project: configFile.sentryProject,
urlPrefix: "~/dist",
include: "./dist",
setCommits: {
@ -117,7 +117,7 @@ module.exports = (env) => {
console.log(colors.green("INFO Sentry Webpack plugins enabled"));
}
prod_config.plugins.push(
prodConfig.plugins.push(
new webpack.EnvironmentPlugin({
GIT_VERSION: git("describe --always"),
GIT_AUTHOR_DATE: git("log -1 --format=%aI"),
@ -126,5 +126,5 @@ module.exports = (env) => {
config: configFile
})
);
return merge(common, prod_config);
return merge(common, prodConfig);
}

View File

@ -82,12 +82,12 @@
<div id="map"></div>
<div id="search">
<input type="text" name="addr" value="" id="addr" size="10" />
<button type="button" onclick="addr_search('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
<button type="button" onclick="addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
class="btn btn-primary">{{ 'Search'|t }}</button>
<div id="results"></div>
</div>
<input type="hidden" name="place" value="" />
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="load_map();"></script>
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="loadMap();"></script>
{% else %}
<label><b>{{ 'Service place'|t }}</b></label>
<input type="text" name="place" required value="{{ values.place }}">

View File

@ -67,12 +67,12 @@
<div id="map"></div>
<div id="search">
<input type="text" name="addr" value="" id="addr" size="10" />
<button type="button" onclick="addr_search('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
<button type="button" onclick="addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');"
class="btn btn-primary">{{ 'Search'|t }}</button>
<div id="results"></div>
</div>
<input type="hidden" name="place" value="" />
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="load_map();"></script>
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="loadMap();"></script>
{% else %}
<label><b>{{ 'Training place'|t }}</b></label>
<input type="text" name="place" required value="{{ values.place }}">

View File

@ -68,7 +68,7 @@
success: function (data) {
toastr.success(`{{ 'Thanks, %s, you have given %s in case of alert.'|t|format(user.name, '${generate_alert_string(id)}') }}`);
clearInterval(window.loadTableInterval); //stop reloading
loadTable({tablePage: "list", use_custom_tableEngine: "default"});
loadTable({tablePage: "list", useCustomTableEngine: "default"});
}
});
}
@ -85,7 +85,7 @@
success: function (data) {
toastr.success(`{{ 'Thanks, %s, you have removed %s in case of alert.'|t|format(user.name, '${generate_alert_string(id)}') }}`);
clearInterval(window.loadTableInterval); //stop reloading
loadTable({tablePage: "list", use_custom_tableEngine: "default"});
loadTable({tablePage: "list", useCustomTableEngine: "default"});
}
});
}
@ -114,7 +114,7 @@
</tbody>
</table>
<script>
loadTable({tablePage: "list", use_custom_tableEngine: "default"});
loadTable({tablePage: "list", useCustomTableEngine: "default"});
</script>
</div>

View File

@ -19,8 +19,8 @@
</tbody>
</table>
<script>
loadTable({tablePage: "log", set_interval: false, callback: function(table_dt) {
table_dt
loadTable({tablePage: "log", setInterval: false, callback: function(setableDt) {
setableDt
.column( '3:visible' )
.order( 'desc' )
.draw();