Merge pull request #605 from mathuo/603-sonarcloud-cleanups

chore: cleanup code
This commit is contained in:
mathuo 2024-05-14 20:39:57 +01:00 committed by GitHub
commit 84d02b9925
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 13 deletions

View File

@ -28,8 +28,7 @@ export interface DockviewGroupPanelFloatingChangeEvent {
readonly location: DockviewGroupLocation; readonly location: DockviewGroupLocation;
} }
// TODO find a better way to initialize and avoid needing null checks const NOT_INITIALIZED_MESSAGE = 'dockview: DockviewGroupPanelApiImpl not initialized';
const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl { export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
private readonly _mutableDisposable = new MutableDisposable(); private readonly _mutableDisposable = new MutableDisposable();
@ -130,15 +129,16 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
} }
initialize(group: DockviewGroupPanel): void { initialize(group: DockviewGroupPanel): void {
this._group = group;
/** /**
* TODO: Annoying initialization order caveat * TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
* *
* Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup. * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
* By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
* finished ensuring the `model` is defined. * finished ensuring the `model` is defined.
*/ */
this._group = group;
queueMicrotask(() => { queueMicrotask(() => {
this._mutableDisposable.value = this._mutableDisposable.value =
this._group!.model.onDidActivePanelChange((event) => { this._group!.model.onDidActivePanelChange((event) => {

View File

@ -1,8 +1,6 @@
class TransferObject { class TransferObject {
constructor() {
// intentionally empty class // intentionally empty class
} }
}
export class PanelTransfer extends TransferObject { export class PanelTransfer extends TransferObject {
constructor( constructor(

View File

@ -828,7 +828,7 @@ export class DockviewComponent
this.updateWatermark(); this.updateWatermark();
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error('dockview: failed to create popout window', err);
}); });
} }
@ -2104,7 +2104,7 @@ export class DockviewComponent
if (id && this._groups.has(options.id!)) { if (id && this._groups.has(options.id!)) {
console.warn( console.warn(
`Duplicate group id ${options?.id}. reassigning group id to avoid errors` `dockview: Duplicate group id ${options?.id}. reassigning group id to avoid errors`
); );
id = undefined; id = undefined;
} }

View File

@ -69,7 +69,7 @@ class Stacktrace {
private constructor(readonly value: string) {} private constructor(readonly value: string) {}
print(): void { print(): void {
console.warn(this.value); console.warn('dockview: stacktrace', this.value);
} }
} }
@ -124,7 +124,7 @@ export class Emitter<T> implements IDisposable {
this._listeners.splice(index, 1); this._listeners.splice(index, 1);
} else if (Emitter.ENABLE_TRACKING) { } else if (Emitter.ENABLE_TRACKING) {
// console.warn( // console.warn(
// `Listener already disposed`, // `dockview: listener already disposed`,
// Stacktrace.create().print() // Stacktrace.create().print()
// ); // );
} }
@ -158,7 +158,10 @@ export class Emitter<T> implements IDisposable {
queueMicrotask(() => { queueMicrotask(() => {
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
for (const listener of this._listeners) { for (const listener of this._listeners) {
console.warn(listener.stacktrace?.print()); console.warn(
'dockview: stacktrace',
listener.stacktrace?.print()
);
} }
}); });
} }