Browse Source

Improve code as per Sonar suggestions (#22224)

pull/22243/head
Michael Telatynski 1 month ago committed by GitHub
parent
commit
ca98529bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      res/decoder-ring/datatypes.js
  2. 2
      res/decoder-ring/decoder.js
  3. 3
      res/decoder-ring/index.html
  4. 1
      res/welcome.html
  5. 2
      src/vector/jitsi/index.ts
  6. 743
      src/vector/mobile_guide/index.html
  7. 2
      src/vector/mobile_guide/index.ts
  8. 7
      src/vector/platform/WebPlatform.ts
  9. 6
      src/vector/static/incompatible-browser.html
  10. 4
      src/vector/static/unable-to-load.html
  11. 23
      webpack.config.js

1
res/decoder-ring/datatypes.js

@ -18,7 +18,6 @@
* ```
*/
class Optional {
static from(value) {
return value && Some.of(value) || None;

2
res/decoder-ring/decoder.js

@ -102,7 +102,7 @@ function fetchAsSubject(endpoint) {
const contentLength = res.headers.get("content-length");
const context = contentLength ? { length: parseInt(contentLength) } : {};
const streamer = observeReadableStream(res.body, context, endpoint);
const streamer = observeReadableStream(res.body, context);
streamer.subscribe((value) => {
fetcher.next(value);
});

3
res/decoder-ring/index.html

@ -1,4 +1,5 @@
<html>
<!doctype html>
<html lang="en">
<head>
<title>Rageshake decoder ring</title>
<script crossorigin src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>

1
res/welcome.html

@ -47,7 +47,6 @@ h1::after {
display: flex;
-webkit-justify-content: space-around;
-ms-flex-pack: distribute;
justify-content: space-around;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;

2
src/vector/jitsi/index.ts

@ -74,7 +74,7 @@ const ack = (ev: CustomEvent<IWidgetApiRequest>) => widgetApi.transport.reply(ev
if (!optional && vals.length !== 1) {
throw new Error(`Expected singular ${name} in query string`);
}
return <string>vals[0];
return vals[0];
};
// If we have these params, expect a widget API to be available (ie. to be in an iframe

743
src/vector/mobile_guide/index.html

File diff suppressed because one or more lines are too long

2
src/vector/mobile_guide/index.ts

@ -17,7 +17,7 @@ function renderConfigError(message: string): void {
const toHide = document.getElementsByClassName("mx_HomePage_container");
const errorContainers = document.getElementsByClassName(
"mx_HomePage_errorContainer",
) as HTMLCollectionOf<HTMLDialogElement>;
) as HTMLCollectionOf<HTMLDivElement>;
for (const e of toHide) {
// We have to clear the content because .style.display='none'; doesn't work

7
src/vector/platform/WebPlatform.ts

@ -106,11 +106,10 @@ export default class WebPlatform extends VectorBasePlatform {
}
getNormalizedAppVersion(version: string): string {
// if version looks like semver with leading v, strip it
// (matches scripts/normalize-version.sh)
const semVerRegex = new RegExp("^v[0-9]+.[0-9]+.[0-9]+(-.+)?$");
// if version looks like semver with leading v, strip it (matches scripts/normalize-version.sh)
const semVerRegex = /^v\d+.\d+.\d+(-.+)?$/;
if (semVerRegex.test(version)) {
return version.substr(1);
return version.substring(1);
}
return version;
}

6
src/vector/static/incompatible-browser.html

@ -53,10 +53,6 @@
margin-top: 30px;
}
.mx_HomePage_header {
align-items: center;
}
.mx_HomePage_col {
display: flex;
flex-direction: row;
@ -144,7 +140,7 @@
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.92 33.32C20.92 34.2478 20.1679 35 19.24 35C13.0544 35 8.04001 29.9856 8.04001 23.8C8.04001 22.8722 8.79217 22.12 9.72001 22.12C10.6478 22.12 11.4 22.8722 11.4 23.8C11.4 28.1299 14.9101 31.64 19.24 31.64C20.1679 31.64 20.92 32.3922 20.92 33.32Z" fill="#0DBD8B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.68 24.9199C3.75216 24.9199 3 24.1678 3 23.2399C3 17.0543 8.01441 12.0399 14.2 12.0399C15.1278 12.0399 15.88 12.7921 15.88 13.7199C15.88 14.6478 15.1278 15.3999 14.2 15.3999C9.87009 15.3999 6.36 18.91 6.36 23.2399C6.36 24.1678 5.60784 24.9199 4.68 24.9199Z" fill="#0DBD8B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M29.32 17.0801C30.2478 17.0801 31 17.8322 31 18.7601C31 24.9457 25.9856 29.9601 19.8 29.9601C18.8722 29.9601 18.12 29.2079 18.12 28.2801C18.12 27.3522 18.8722 26.6001 19.8 26.6001C24.1299 26.6001 27.64 23.09 27.64 18.7601C27.64 17.8322 28.3922 17.0801 29.32 17.0801Z" fill="#0DBD8B"/>
</svg>
</svg>
</span>
<h1>Unsupported browser</h1>
</div>

4
src/vector/static/unable-to-load.html

@ -54,10 +54,6 @@
margin-top: 30px;
}
.mx_HomePage_header {
align-items: center;
}
.mx_HomePage_col {
display: flex;
flex-direction: row;

23
webpack.config.js

@ -34,8 +34,7 @@ const cssThemes = {
function getActiveThemes() {
// Default to `light` theme when the MATRIX_THEMES environment variable is not defined.
const theme = process.env.MATRIX_THEMES ?? 'light';
const themes = theme.split(',').filter(x => x).map(x => x.trim()).filter(x => x);
return themes;
return theme.split(',').map(x => x.trim()).filter(Boolean);
}
// See docs/customisations.md
@ -80,7 +79,6 @@ module.exports = (env, argv) => {
const nodeEnv = argv.mode;
const devMode = nodeEnv !== 'production';
const useHMR = process.env.CSS_HOT_RELOAD === '1' && devMode;
const fullPageErrors = process.env.FULL_PAGE_ERRORS === '1' && devMode;
const enableMinification = !devMode && !process.env.CI_PACKAGE;
const development = {};
@ -99,17 +97,16 @@ module.exports = (env, argv) => {
}
}
// Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we
// Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early, so we
// don't have to call them over and over. We also resolve to the package.json instead of the src
// directory so we don't have to rely on a index.js or similar file existing.
// directory, so we don't have to rely on an index.js or similar file existing.
const reactSdkSrcDir = path.resolve(require.resolve("matrix-react-sdk/package.json"), '..', 'src');
const jsSdkSrcDir = path.resolve(require.resolve("matrix-js-sdk/package.json"), '..', 'src');
const ACTIVE_THEMES = getActiveThemes();
function getThemesImports() {
const imports = ACTIVE_THEMES.map((t, index) => {
const themeImportPath = cssThemes[`theme-${ t }`].replace('./node_modules/', '');
return themeImportPath;
const imports = ACTIVE_THEMES.map((t) => {
return cssThemes[`theme-${ t }`].replace('./node_modules/', ''); // theme import path
});
const s = JSON.stringify(ACTIVE_THEMES);
return `
@ -483,7 +480,7 @@ module.exports = (env, argv) => {
esModule: false,
name: '[name].[hash:7].[ext]',
outputPath: getAssetOutputPath,
publicPath: function (url, resourcePath) {
publicPath: function(url, resourcePath) {
const outputPath = getAssetOutputPath(url, resourcePath);
return toPublicPath(outputPath);
},
@ -495,13 +492,13 @@ module.exports = (env, argv) => {
esModule: false,
name: '[name].[hash:7].[ext]',
outputPath: getAssetOutputPath,
publicPath: function (url, resourcePath) {
publicPath: function(url, resourcePath) {
const outputPath = getAssetOutputPath(url, resourcePath);
return toPublicPath(outputPath);
},
},
},
]
],
},
{
test: /\.svg$/,
@ -513,7 +510,7 @@ module.exports = (env, argv) => {
esModule: false,
name: '[name].[hash:7].[ext]',
outputPath: getAssetOutputPath,
publicPath: function (url, resourcePath) {
publicPath: function(url, resourcePath) {
// CSS image usages end up in the `bundles/[hash]` output
// directory, so we adjust the final path to navigate up
// twice.
@ -522,7 +519,7 @@ module.exports = (env, argv) => {
},
},
},
]
],
},
{
test: /\.(gif|png|ttf|woff|woff2|xml|ico)$/,

Loading…
Cancel
Save