chore: fix sonar issues

This commit is contained in:
mathuo 2023-10-22 15:40:11 +01:00
parent 318cbd6854
commit 882c1353c7
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
18 changed files with 42 additions and 49 deletions

View File

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

View File

@ -1,4 +1,3 @@
import { toHaveDescription } from '@testing-library/jest-dom/matchers';
import { import {
getElementsByTagName, getElementsByTagName,
quasiDefaultPrevented, quasiDefaultPrevented,

View File

@ -35,7 +35,7 @@ export class DefaultDockviewDeserialzier implements IPanelDeserializer {
const contentComponent = viewData const contentComponent = viewData
? viewData.content.id ? viewData.content.id
: panelData.contentComponent || 'unknown'; : panelData.contentComponent ?? 'unknown';
const tabComponent = viewData const tabComponent = viewData
? viewData.tab?.id ? viewData.tab?.id
: panelData.tabComponent; : panelData.tabComponent;
@ -56,8 +56,8 @@ export class DefaultDockviewDeserialzier implements IPanelDeserializer {
); );
panel.init({ panel.init({
title: title || panelId, title: title ?? panelId,
params: params || {}, params: params ?? {},
}); });
return panel; return panel;

View File

@ -55,7 +55,6 @@ import {
GroupDragEvent, GroupDragEvent,
TabDragEvent, TabDragEvent,
} from './components/titlebar/tabsContainer'; } from './components/titlebar/tabsContainer';
import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi';
const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100; const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
@ -303,7 +302,7 @@ export class DockviewComponent
constructor(options: DockviewComponentOptions) { constructor(options: DockviewComponentOptions) {
super({ super({
proportionalLayout: true, proportionalLayout: true,
orientation: options.orientation || Orientation.HORIZONTAL, orientation: options.orientation ?? Orientation.HORIZONTAL,
styles: options.styles, styles: options.styles,
parentElement: options.parentElement, parentElement: options.parentElement,
}); });
@ -407,7 +406,7 @@ export class DockviewComponent
this.moveGroupOrPanel( this.moveGroupOrPanel(
this.orthogonalize(event.position), this.orthogonalize(event.position),
data.groupId, data.groupId,
data.panelId || undefined, data.panelId ?? undefined,
'center' 'center'
); );
} else { } else {
@ -1214,7 +1213,7 @@ export class DockviewComponent
if (!destinationTarget || destinationTarget === 'center') { if (!destinationTarget || destinationTarget === 'center') {
const groupItem: IDockviewPanel | undefined = const groupItem: IDockviewPanel | undefined =
sourceGroup?.model.removePanel(sourceItemId) || sourceGroup?.model.removePanel(sourceItemId) ??
this.panels.find((panel) => panel.id === sourceItemId); this.panels.find((panel) => panel.id === sourceItemId);
if (!groupItem) { if (!groupItem) {
@ -1278,7 +1277,7 @@ export class DockviewComponent
this.doAddGroup(targetGroup, location); this.doAddGroup(targetGroup, location);
} else { } else {
const groupItem: IDockviewPanel | undefined = const groupItem: IDockviewPanel | undefined =
sourceGroup?.model.removePanel(sourceItemId) || sourceGroup?.model.removePanel(sourceItemId) ??
this.panels.find((panel) => panel.id === sourceItemId); this.panels.find((panel) => panel.id === sourceItemId);
if (!groupItem) { if (!groupItem) {
@ -1431,7 +1430,7 @@ export class DockviewComponent
): DockviewPanel { ): DockviewPanel {
const contentComponent = options.component; const contentComponent = options.component;
const tabComponent = const tabComponent =
options.tabComponent || this.options.defaultTabComponent; options.tabComponent ?? this.options.defaultTabComponent;
const view = new DockviewPanelModel( const view = new DockviewPanelModel(
this, this,
@ -1448,8 +1447,8 @@ export class DockviewComponent
view view
); );
panel.init({ panel.init({
title: options.title || options.id, title: options.title ?? options.id,
params: options?.params || {}, params: options?.params ?? {},
}); });
return panel; return panel;

View File

@ -322,7 +322,7 @@ export class DockviewGroupPanelModel
); );
this.header.hidden = !!options.hideHeader; this.header.hidden = !!options.hideHeader;
this.locked = options.locked || false; this.locked = options.locked ?? false;
this.addDisposables( this.addDisposables(
this._onTabDragStart, this._onTabDragStart,

View File

@ -117,7 +117,7 @@ export class DockviewPanel
public update(event: PanelUpdateEvent): void { public update(event: PanelUpdateEvent): void {
// merge the new parameters with the existing parameters // merge the new parameters with the existing parameters
this._params = { this._params = {
...(this._params || {}), ...(this._params ?? {}),
...event.params, ...event.params,
}; };

View File

@ -97,7 +97,7 @@ export class DockviewPanelModel implements IDockviewPanelModel {
return createComponent( return createComponent(
id, id,
componentName, componentName,
this.accessor.options.components || {}, this.accessor.options.components ?? {},
this.accessor.options.frameworkComponents, this.accessor.options.frameworkComponents,
this.accessor.options.frameworkComponentFactory?.content this.accessor.options.frameworkComponentFactory?.content
); );

View File

@ -281,7 +281,7 @@ export abstract class BaseGrid<T extends IGridPanelView>
public layout(width: number, height: number, forceResize?: boolean): void { public layout(width: number, height: number, forceResize?: boolean): void {
const different = const different =
forceResize || width !== this.width || height !== this.height; forceResize ?? (width !== this.width || height !== this.height);
if (!different) { if (!different) {
return; return;

View File

@ -190,8 +190,8 @@ export class GridviewComponent
const view = createComponent( const view = createComponent(
data.id, data.id,
data.component, data.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkComponentFactory this.options.frameworkComponentFactory
? { ? {
createComponent: createComponent:
@ -308,7 +308,7 @@ export class GridviewComponent
public addPanel<T extends object = Parameters>( public addPanel<T extends object = Parameters>(
options: AddComponentOptions<T> options: AddComponentOptions<T>
): IGridviewPanel { ): IGridviewPanel {
let relativeLocation: number[] = options.location || [0]; let relativeLocation: number[] = options.location ?? [0];
if (options.position?.referencePanel) { if (options.position?.referencePanel) {
const referenceGroup = this._groups.get( const referenceGroup = this._groups.get(
@ -337,8 +337,8 @@ export class GridviewComponent
const view = createComponent( const view = createComponent(
options.id, options.id,
options.component, options.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkComponentFactory this.options.frameworkComponentFactory
? { ? {
createComponent: createComponent:
@ -349,7 +349,7 @@ export class GridviewComponent
); );
view.init({ view.init({
params: options.params || {}, params: options.params ?? {},
minimumWidth: options.minimumWidth, minimumWidth: options.minimumWidth,
maximumWidth: options.maximumWidth, maximumWidth: options.maximumWidth,
minimumHeight: options.minimumHeight, minimumHeight: options.minimumHeight,

View File

@ -240,8 +240,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
const body = createComponent( const body = createComponent(
options.id, options.id,
options.component, options.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
createComponent: createComponent:
@ -256,7 +256,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
header = createComponent( header = createComponent(
options.id, options.id,
options.headerComponent, options.headerComponent,
this.options.headerComponents || {}, this.options.headerComponents ?? {},
this.options.headerframeworkComponents, this.options.headerframeworkComponents,
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
@ -290,7 +290,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
typeof options.index === 'number' ? options.index : undefined; typeof options.index === 'number' ? options.index : undefined;
view.init({ view.init({
params: options.params || {}, params: options.params ?? {},
minimumBodySize: options.minimumBodySize, minimumBodySize: options.minimumBodySize,
maximumBodySize: options.maximumBodySize, maximumBodySize: options.maximumBodySize,
isExpanded: options.isExpanded, isExpanded: options.isExpanded,
@ -377,8 +377,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
const body = createComponent( const body = createComponent(
data.id, data.id,
data.component, data.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
createComponent: createComponent:
@ -394,8 +394,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
header = createComponent( header = createComponent(
data.id, data.id,
data.headerComponent, data.headerComponent,
this.options.headerComponents || {}, this.options.headerComponents ?? {},
this.options.headerframeworkComponents || {}, this.options.headerframeworkComponents ?? {},
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
createComponent: createComponent:
@ -424,7 +424,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
queue.push(() => { queue.push(() => {
panel.init({ panel.init({
params: data.params || {}, params: data.params ?? {},
minimumBodySize: view.minimumSize, minimumBodySize: view.minimumSize,
maximumBodySize: view.maximumSize, maximumBodySize: view.maximumSize,
title: data.title, title: data.title,

View File

@ -261,8 +261,8 @@ export class SplitviewComponent
const view = createComponent( const view = createComponent(
options.id, options.id,
options.component, options.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
createComponent: createComponent:
@ -361,8 +361,8 @@ export class SplitviewComponent
const panel = createComponent( const panel = createComponent(
data.id, data.id,
data.component, data.component,
this.options.components || {}, this.options.components ?? {},
this.options.frameworkComponents || {}, this.options.frameworkComponents ?? {},
this.options.frameworkWrapper this.options.frameworkWrapper
? { ? {
createComponent: createComponent:
@ -374,7 +374,7 @@ export class SplitviewComponent
queue.push(() => { queue.push(() => {
panel.init({ panel.init({
params: data.params || {}, params: data.params ?? {},
minimumSize: data.minimumSize, minimumSize: data.minimumSize,
maximumSize: data.maximumSize, maximumSize: data.maximumSize,
snap: view.snap, snap: view.snap,

View File

@ -7,7 +7,6 @@ import { SplitviewPanelApiImpl } from '../api/splitviewPanelApi';
import { LayoutPriority, Orientation } from './splitview'; import { LayoutPriority, Orientation } from './splitview';
import { FunctionOrValue } from '../types'; import { FunctionOrValue } from '../types';
import { Emitter, Event } from '../events'; import { Emitter, Event } from '../events';
import { CompositeDisposable } from '../lifecycle';
export interface ISplitviewPanel export interface ISplitviewPanel
extends BasePanelViewExported<SplitviewPanelApiImpl> { extends BasePanelViewExported<SplitviewPanelApiImpl> {

View File

@ -139,7 +139,7 @@ export const DockviewReact = React.forwardRef(
}, },
}; };
const frameworkTabComponents = props.tabComponents || {}; const frameworkTabComponents = props.tabComponents ?? {};
if (props.defaultTabComponent) { if (props.defaultTabComponent) {
frameworkTabComponents[DEFAULT_REACT_TAB] = frameworkTabComponents[DEFAULT_REACT_TAB] =
@ -267,7 +267,7 @@ export const DockviewReact = React.forwardRef(
return; return;
} }
const frameworkTabComponents = props.tabComponents || {}; const frameworkTabComponents = props.tabComponents ?? {};
if (props.defaultTabComponent) { if (props.defaultTabComponent) {
frameworkTabComponents[DEFAULT_REACT_TAB] = frameworkTabComponents[DEFAULT_REACT_TAB] =

View File

@ -60,7 +60,7 @@ export class ReactWatermarkPart implements IWatermarkRenderer {
this.parameters.params = params.params; this.parameters.params = params.params;
} }
this.part?.update({ params: this.parameters?.params || {} }); this.part?.update({ params: this.parameters?.params ?? {} });
} }
layout(_width: number, _height: number): void { layout(_width: number, _height: number): void {

View File

@ -51,7 +51,7 @@ export const GridviewReact = React.forwardRef(
typeof props.proportionalLayout === 'boolean' typeof props.proportionalLayout === 'boolean'
? props.proportionalLayout ? props.proportionalLayout
: true, : true,
orientation: props.orientation || Orientation.HORIZONTAL, orientation: props.orientation ?? Orientation.HORIZONTAL,
frameworkComponents: props.components, frameworkComponents: props.components,
frameworkComponentFactory: { frameworkComponentFactory: {
createComponent: (id: string, componentId, component) => { createComponent: (id: string, componentId, component) => {

View File

@ -23,7 +23,7 @@ export class ReactGridPanelView extends GridviewPanel {
this.reactPortalStore, this.reactPortalStore,
this.reactComponent, this.reactComponent,
{ {
params: this._params?.params || {}, params: this._params?.params ?? {},
api: this.api, api: this.api,
containerApi: new GridviewApi( containerApi: new GridviewApi(
(this._params as GridviewInitParameters).accessor (this._params as GridviewInitParameters).accessor

View File

@ -41,7 +41,7 @@ export const SplitviewReact = React.forwardRef(
React.useEffect(() => { React.useEffect(() => {
const splitview = new SplitviewComponent({ const splitview = new SplitviewComponent({
parentElement: domRef.current!, parentElement: domRef.current!,
orientation: props.orientation || Orientation.HORIZONTAL, orientation: props.orientation ?? Orientation.HORIZONTAL,
frameworkComponents: props.components, frameworkComponents: props.components,
frameworkWrapper: { frameworkWrapper: {
createComponent: ( createComponent: (

View File

@ -22,7 +22,7 @@ export class ReactPanelView extends SplitviewPanel {
this.reactPortalStore, this.reactPortalStore,
this.reactComponent, this.reactComponent,
{ {
params: this._params?.params || {}, params: this._params?.params ?? {},
api: this.api, api: this.api,
containerApi: new SplitviewApi( containerApi: new SplitviewApi(
(this._params as PanelViewInitParameters).accessor (this._params as PanelViewInitParameters).accessor