Merge pull request #31 from mathuo/23-increase-test-coverage

chore: reduce sonar smells
This commit is contained in:
mathuo 2022-03-12 22:33:17 +00:00 committed by GitHub
commit 2e7711486b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 27 deletions

View File

@ -221,11 +221,6 @@ export class DockviewComponent
typeof options.orientation === 'string' &&
this.options.orientation !== options.orientation;
// TODO support style update
// const hasStylesChanged =
// typeof options.styles === 'object' &&
// this.options.styles !== options.styles;
this._options = { ...this.options, ...options };
if (hasOrientationChanged) {
@ -409,16 +404,14 @@ export class DockviewComponent
}
fireMouseEvent(event: LayoutMouseEvent): void {
switch (event.kind) {
case MouseEventKind.CONTEXT_MENU:
if (event.tab && event.panel) {
this._onTabContextMenu.fire({
event: event.event,
api: this._api,
panel: event.panel,
});
}
break;
if (event.kind === MouseEventKind.CONTEXT_MENU) {
if (event.tab && event.panel) {
this._onTabContextMenu.fire({
event: event.event,
api: this._api,
panel: event.panel,
});
}
}
}

View File

@ -42,8 +42,6 @@ export class Emitter<T> implements IDisposable {
listener(this._last);
}
const firstListener = this._listeners.length === 0;
this._listeners.push(listener);
return {

View File

@ -618,9 +618,10 @@ export class Gridview implements IDisposable {
return node.view;
}
const sibling = parent.children[0];
if (pathToParent.length === 0) {
// parent is root
const sibling = parent.children[0];
if (sibling instanceof LeafNode) {
return node.view;
@ -635,7 +636,6 @@ export class Gridview implements IDisposable {
const [grandParent, ..._] = [...pathToParent].reverse();
const [parentIndex, ...__] = [...rest].reverse();
const sibling = parent.children[0];
const isSiblingVisible = parent.isChildVisible(0);
parent.removeChild(0, sizing);

View File

@ -261,12 +261,10 @@ export class TabsContainer
return;
}
switch (event.kind) {
case MouseEventKind.CLICK:
this.group.model.openPanel(panel, {
skipFocus: alreadyFocused,
});
break;
if (event.kind === MouseEventKind.CLICK) {
this.group.model.openPanel(panel, {
skipFocus: alreadyFocused,
});
}
}),
tabToAdd.onDrop((event) => {

View File

@ -92,7 +92,6 @@ export class ReactPart<P extends object, C extends object = {}>
throw new Error('invalid operation: resource is already disposed');
}
// TODO use a better check for isReactFunctionalComponent
if (typeof this.component !== 'function') {
/**
* we know this isn't a React.FunctionComponent so throw an error here.
@ -100,7 +99,7 @@ export class ReactPart<P extends object, C extends object = {}>
* for the same reason, at least at this point we will emit a sensible stacktrace.
*/
throw new Error(
'invalid operation: only functional components are supported'
'Invalid Operation. dockview only supports React Functional Components.'
);
}