Skip to content

Commit

Permalink
SonarCloud: mark as readonly
Browse files Browse the repository at this point in the history
SonarCloud: mark as readonly

SonarCloud: mark as readonly
  • Loading branch information
oeni2023 committed Nov 29, 2024
1 parent df77d1f commit ce32b47
Show file tree
Hide file tree
Showing 32 changed files with 99 additions and 99 deletions.
4 changes: 2 additions & 2 deletions ui/src/LimitCameraHeightToDepth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type {Scene} from 'cesium';


export default class LimitCameraHeightToDepth {
private scene: Scene;
private depth: number;
private readonly scene: Scene;
private readonly depth: number;

constructor(scene: Scene, depth: number) {
this.scene = scene;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/MapChooser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type {BaseLayerConfig} from './viewer';
import MainStore from './store/main';

export default class MapChooser {
private viewer: Viewer;
private config: BaseLayerConfig[];
private readonly viewer: Viewer;
private readonly config: BaseLayerConfig[];
public selectedMap: BaseLayerConfig;
public elements: NgmMapChooser[] = [];

Expand Down
4 changes: 2 additions & 2 deletions ui/src/NavigableVolumeLimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {Scene, Rectangle} from 'cesium';
*/
export default class NavigableVolumeLimiter {
private blockLimiter = false;
private boundingSphere: BoundingSphere;
private ratioFunction: (height: number) => number;
private readonly boundingSphere: BoundingSphere;
private readonly ratioFunction: (height: number) => number;

constructor(scene: Scene, rectangle: Rectangle, height: number, ratioFunction: (height: number) => number) {
this.boundingSphere = BoundingSphere.fromRectangle3D(rectangle, Ellipsoid.WGS84, height);
Expand Down
8 changes: 4 additions & 4 deletions ui/src/draw/CesiumDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export type DrawEndDetails = {
}

export class CesiumDraw extends EventTarget {
private viewer_: Viewer;
private strokeColor_: Color;
private strokeWidth_: number;
private fillColor_: Color;
private readonly viewer_: Viewer;
private readonly strokeColor_: Color;
private readonly strokeWidth_: number;
private readonly fillColor_: Color;
private eventHandler_: ScreenSpaceEventHandler | undefined;
private activePoints_: Cartesian3[] = [];
private activePoint_: Cartesian3 | undefined;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/elements/dashboard/ngm-add-member-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class NgmAddMemberForm extends LitElementI18n {
accessor email: string | undefined;
@state()
accessor roleNotSelected = false;
private roleDropdownItems: DropdownItem[] = [
private readonly roleDropdownItems: DropdownItem[] = [
{title: i18next.t('dashboard_project_viewer'), value: 'viewer'},
{title: i18next.t('dashboard_project_editor'), value: 'editor'},
];
Expand Down Expand Up @@ -105,4 +105,4 @@ export class NgmAddMemberForm extends LitElementI18n {
return this;
}

}
}
2 changes: 1 addition & 1 deletion ui/src/elements/dashboard/ngm-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class NgmDashboard extends LitElementI18n {
private geometries: NgmGeometry[] = [];
private recentlyViewedIds: Array<string> = [];
private userEmail: string | undefined;
private tempKmlDataSource = new CustomDataSource('tempKmlDataSource');
private readonly tempKmlDataSource = new CustomDataSource('tempKmlDataSource');

@consume({context: apiClientContext})
accessor apiClient!: ApiClient;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/elements/hide-overflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {customElement} from 'lit/decorators.js';

@customElement('hide-overflow')
export class HideOverflow extends LitElement {
private observer: IntersectionObserver;
private readonly observer: IntersectionObserver;

constructor() {
super();
Expand Down
4 changes: 2 additions & 2 deletions ui/src/elements/ngm-coordinate-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class NgmCoordinatePopup extends LitElementI18n {
@state()
accessor terrainDistance = '';
private eventHandler: ScreenSpaceEventHandler | undefined;
private integerFormat = new Intl.NumberFormat('de-CH', {
private readonly integerFormat = new Intl.NumberFormat('de-CH', {
maximumFractionDigits: 1
});

Expand Down Expand Up @@ -98,4 +98,4 @@ export class NgmCoordinatePopup extends LitElementI18n {
createRenderRoot() {
return this;
}
}
}
2 changes: 1 addition & 1 deletion ui/src/elements/ngm-cursor-information.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class NgmCursorInformation extends LitElementI18n {
private unlistenMoveStart: any;
private unlistenMoveEnd: any;
// always use the 'de-CH' locale to always have the simple tick as thousands separator
private integerFormat = new Intl.NumberFormat('de-CH', {
private readonly integerFormat = new Intl.NumberFormat('de-CH', {
maximumFractionDigits: 1
});

Expand Down
2 changes: 1 addition & 1 deletion ui/src/elements/ngm-map-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class NgmMapConfiguration extends LitElementI18n {
accessor baseMapId = 'ch.swisstopo.pixelkarte-grau';
@query('ngm-map-chooser')
accessor mapChooserElement;
private debouncedOpacityUpdate = debounce((evt: Event) => this.updateOpacity(Number((<HTMLInputElement>evt.target).value)), 250);
private readonly debouncedOpacityUpdate = debounce((evt: Event) => this.updateOpacity(Number((<HTMLInputElement>evt.target).value)), 250);
private prevExaggeration: number = 1;

constructor() {
Expand Down
14 changes: 7 additions & 7 deletions ui/src/elements/ngm-nav-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class NgmNavTools extends LitElementI18n {
private zoomingOut = false;
private unlistenFromPostRender: Event.RemoveCallback | null = null;
private eventHandler: ScreenSpaceEventHandler | undefined;
private stopZoomFunction: () => void = () => this.stopZoom();
private readonly stopZoomFunction: () => void = () => this.stopZoom();
private refIcon: Entity = new Entity({
position: Cartesian3.ZERO,
show: false,
Expand All @@ -70,14 +70,14 @@ export class NgmNavTools extends LitElementI18n {
}
});
private moveRef = false;
private julianDate = new JulianDate();
private readonly julianDate = new JulianDate();
private axisDataSource: CustomDataSource | undefined;
private axisCenter: Cartesian3 | undefined;
private oldPolylineUpdate: any = PolylineCollection.prototype.update;
private xyAxisCalculation = (axis, side) => [this.axisCenter, positionFromPxDistance(this.viewer!.scene, this.axisCenter!, AXIS_LENGTH, axis, side)];
private xAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('x', -1), false);
private yAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('y', 1), false);
private zAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('z', -1), false);
private readonly oldPolylineUpdate: any = PolylineCollection.prototype.update;
private readonly xyAxisCalculation = (axis, side) => [this.axisCenter, positionFromPxDistance(this.viewer!.scene, this.axisCenter!, AXIS_LENGTH, axis, side)];
private readonly xAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('x', -1), false);
private readonly yAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('y', 1), false);
private readonly zAxisCallback = new CallbackProperty(() => this.xyAxisCalculation('z', -1), false);
private exaggeration = 1;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/elements/ngm-side-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SideBar extends LitElementI18n {
private zoomedToPosition = false;
private accordionInited = false;
private shareListenerAdded = false;
private shareDownListener = evt => {
private readonly shareDownListener = evt => {
if (!evt.composedPath().includes(this)) this.activePanel = null;
};

Expand Down
10 changes: 5 additions & 5 deletions ui/src/layers/ngm-layers-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class NgmLayersItem extends LitElementI18n {
accessor movable = false;
@query('.menu')
accessor actionMenu!: HTMLElement;
private toggleItemSelection = () => this.movable ? Sortable.utils.select(this) : Sortable.utils.deselect(this);
private debouncedOpacityChange = debounce(() => this.changeOpacity(), 250, true);
private readonly toggleItemSelection = () => this.movable ? Sortable.utils.select(this) : Sortable.utils.deselect(this);
private readonly debouncedOpacityChange = debounce(() => this.changeOpacity(), 250, true);

firstUpdated() {
$(this.querySelector('.ui.dropdown')!).dropdown();
Expand Down Expand Up @@ -166,9 +166,9 @@ export class NgmLayersItem extends LitElementI18n {
${i18next.t('dtd_legend')}
</div>` : ''}
${this.config?.geocatId ? html`
<a
class="item"
href="${this.geocatLink(this.config.geocatId)}"
<a
class="item"
href="${this.geocatLink(this.config.geocatId)}"
target="_blank" rel="noopener">
Geocat.ch
</a>` : ''}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/measure/MeasureTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class MeasureTool {
private readonly measureDataSource = new CustomDataSource('measure');
private readonly measureOptions: MeasureOptions;
private measureToolActive = false;
private screenSpaceEventHandler: ScreenSpaceEventHandler | undefined;
private readonly screenSpaceEventHandler: ScreenSpaceEventHandler | undefined;
private measurePositions: Cartesian3[] = [];
private highlightEntity: Entity | undefined;
private points: Entity[] = [];
Expand Down Expand Up @@ -164,4 +164,4 @@ export default class MeasureTool {
this.measureDataSource.entities.removeAll();
this.viewer?.scene.render();
}
}
}
2 changes: 1 addition & 1 deletion ui/src/ngm-app-boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ConfigService} from './api/config.service';

@customElement('ngm-app-boot')
export class NgmAppBoot extends LitElement {
private viewerInitialization = new Task(this, {
private readonly viewerInitialization = new Task(this, {
task: async () => {
const clientConfig = await new ConfigService().getConfig() as ClientConfig;
if (!clientConfig) {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/query/ObjectSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function isTemplateResult(value) {
}

export default class ObjectSelector {
private viewer: Viewer;
private scene: Scene;
private readonly viewer: Viewer;
private readonly scene: Scene;
selectedObj: any | null = null; // todo improve types
savedColor: Color | null = null;

Expand Down
24 changes: 12 additions & 12 deletions ui/src/slicer/SlicerArrows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ export default class SlicerArrows {

private enableInputs = true;

private scratchBoundingSphere_ = new BoundingSphere();
private scratchArrowPosition2d_ = new Cartesian2();
private scratchOppositeArrowPosition2d_ = new Cartesian2();
private scratchAxisVector2d_ = new Cartesian2();
private scratchMouseMoveVector_ = new Cartesian2();
private scratchObjectMoveVector2d_ = new Cartesian2();
private scratchNewArrowPosition2d_ = new Cartesian2();
private axisVector3d = new Cartesian3();
private scratchLeft = new Cartesian3();
private scratchRight = new Cartesian3();
private scratchTop = new Cartesian3();
private scratchBottom = new Cartesian3();
private readonly scratchBoundingSphere_ = new BoundingSphere();
private readonly scratchArrowPosition2d_ = new Cartesian2();
private readonly scratchOppositeArrowPosition2d_ = new Cartesian2();
private readonly scratchAxisVector2d_ = new Cartesian2();
private readonly scratchMouseMoveVector_ = new Cartesian2();
private readonly scratchObjectMoveVector2d_ = new Cartesian2();
private readonly scratchNewArrowPosition2d_ = new Cartesian2();
private readonly axisVector3d = new Cartesian3();
private readonly scratchLeft = new Cartesian3();
private readonly scratchRight = new Cartesian3();
private readonly scratchTop = new Cartesian3();
private readonly scratchBottom = new Cartesian3();

private eventHandler: (ScreenSpaceEventHandler | null) = null;
highlightedArrow: Entity | undefined = undefined;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {BehaviorSubject} from 'rxjs';
import type {AuthUser} from '../authService';

export default class AuthStore {
private static userSubject = new BehaviorSubject<AuthUser | null>(null);
private static readonly userSubject = new BehaviorSubject<AuthUser | null>(null);

static get user(): BehaviorSubject<AuthUser | null> {
return this.userSubject;
Expand Down
12 changes: 6 additions & 6 deletions ui/src/store/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export type ProjectParamSubject = {
export type ProjectMode = 'edit' | 'viewEdit' | 'viewOnly' | undefined

export default class DashboardStore {
private static selectedTopicOrProjectSubject = new BehaviorSubject<Topic | Project | undefined>(undefined);
private static viewIndexSubject = new Subject<number | undefined>();
private static topicOrProjectParamSubject = new BehaviorSubject<TopicParamSubject | ProjectParamSubject | undefined>(undefined);
private static projectModeSubject = new BehaviorSubject<ProjectMode>(undefined);
private static geometriesSubject = new Subject<NgmGeometry[]>();
private static showSaveOrCancelWarningSubject = new Subject<boolean>();
private static readonly selectedTopicOrProjectSubject = new BehaviorSubject<Topic | Project | undefined>(undefined);
private static readonly viewIndexSubject = new Subject<number | undefined>();
private static readonly topicOrProjectParamSubject = new BehaviorSubject<TopicParamSubject | ProjectParamSubject | undefined>(undefined);
private static readonly projectModeSubject = new BehaviorSubject<ProjectMode>(undefined);
private static readonly geometriesSubject = new Subject<NgmGeometry[]>();
private static readonly showSaveOrCancelWarningSubject = new Subject<boolean>();

static get selectedTopicOrProject(): BehaviorSubject<Topic | Project | undefined> {
return this.selectedTopicOrProjectSubject;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/store/draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {BehaviorSubject} from 'rxjs';
import type {CesiumDraw} from '../draw/CesiumDraw';

export default class DrawStore {
private static drawSubject = new BehaviorSubject<CesiumDraw | undefined>(undefined);
private static drawStateSubject = new BehaviorSubject<boolean>(false);
private static readonly drawSubject = new BehaviorSubject<CesiumDraw | undefined>(undefined);
private static readonly drawStateSubject = new BehaviorSubject<boolean>(false);
static measureState = new BehaviorSubject<boolean>(false);

static setDrawState(value: boolean): void {
Expand Down
18 changes: 9 additions & 9 deletions ui/src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import {getIonToken, setIonToken} from '../permalink';
import {IonAsset} from '../api-ion';

export default class MainStore {
private static viewerSubject = new BehaviorSubject<Viewer | null>(null);
private static mapChooserSubject = new BehaviorSubject<MapChooser | null>(null);
private static layersRemovedSubject = new Subject<void>();
private static syncMapSubject = new Subject<void>();
private static voxelLayerCountSubject = new BehaviorSubject<string[]>([]);
private static ionTokenSubject = new BehaviorSubject<string | null>(getIonToken());
private static ionAssetSubject = new Subject<IonAsset>();
private static removeIonAssetsSubject = new Subject<void>();
private static readonly viewerSubject = new BehaviorSubject<Viewer | null>(null);
private static readonly mapChooserSubject = new BehaviorSubject<MapChooser | null>(null);
private static readonly layersRemovedSubject = new Subject<void>();
private static readonly syncMapSubject = new Subject<void>();
private static readonly voxelLayerCountSubject = new BehaviorSubject<string[]>([]);
private static readonly ionTokenSubject = new BehaviorSubject<string | null>(getIonToken());
private static readonly ionAssetSubject = new Subject<IonAsset>();
private static readonly removeIonAssetsSubject = new Subject<void>();
static setUrlLayersSubject = new Subject<void>();
static syncLayerParams = new Subject<void>();
/**
* List of uploaded KML dataSource names. Required to get list of uploaded layers and update properties in batch (e.g. exaggeration)
* @private
*/
private static uploadedKmlListSubject = new BehaviorSubject<string[]>([]);
private static readonly uploadedKmlListSubject = new BehaviorSubject<string[]>([]);

static get viewer(): BehaviorSubject<Viewer | null> {
return this.viewerSubject;
Expand Down
10 changes: 5 additions & 5 deletions ui/src/store/navTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type {LockType} from '../elements/ngm-cam-configuration';
import type {Cartesian3} from 'cesium';

export default class NavToolsStore {
private static syncTargetPointSubject = new Subject<void>();
private static cameraHeightSubject = new Subject<number>();
private static hideTargetPointSubject = new Subject<void>();
private static navLockTypeSubject = new BehaviorSubject<LockType>('');
private static targetPointPositionSubject = new BehaviorSubject<Cartesian3 | undefined>(undefined);
private static readonly syncTargetPointSubject = new Subject<void>();
private static readonly cameraHeightSubject = new Subject<number>();
private static readonly hideTargetPointSubject = new Subject<void>();
private static readonly navLockTypeSubject = new BehaviorSubject<LockType>('');
private static readonly targetPointPositionSubject = new BehaviorSubject<Cartesian3 | undefined>(undefined);
static exaggerationChanged = new Subject<number>();

static get syncTargetPoint() {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/store/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Subject} from 'rxjs';
import type {QueryResult} from '../query/types';

export default class QueryStore {
private static objectInfoSubject = new Subject<QueryResult | undefined>();
private static readonly objectInfoSubject = new Subject<QueryResult | undefined>();

static setObjectInfo(attributes: QueryResult | undefined): void {
if (attributes && !Object.getOwnPropertyNames(attributes).length)
Expand Down
16 changes: 8 additions & 8 deletions ui/src/store/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export interface GeometryAction {
export type GeometryCreateOptions = {geometry: NgmGeometry, slice?: boolean};

export default class ToolboxStore {
private static slicerSubject = new BehaviorSubject<Slicer | null>(null);
private static rtcSubject = new Subject<GeometryCreateOptions>();
private static geometriesSubject = new BehaviorSubject<NgmGeometry[]>([]);
private static noEditGeometriesSubject = new BehaviorSubject<NgmGeometry[]>([]);
private static openedGeometryOptionsSubject = new BehaviorSubject<OpenedGeometryOptions | null>(null);
private static sliceGeometrySubject = new BehaviorSubject<NgmGeometry | null | undefined>(null);
private static geomActionSubject = new Subject<GeometryAction>();
private static syncSliceSubject = new Subject<void>();
private static readonly slicerSubject = new BehaviorSubject<Slicer | null>(null);
private static readonly rtcSubject = new Subject<GeometryCreateOptions>();
private static readonly geometriesSubject = new BehaviorSubject<NgmGeometry[]>([]);
private static readonly noEditGeometriesSubject = new BehaviorSubject<NgmGeometry[]>([]);
private static readonly openedGeometryOptionsSubject = new BehaviorSubject<OpenedGeometryOptions | null>(null);
private static readonly sliceGeometrySubject = new BehaviorSubject<NgmGeometry | null | undefined>(null);
private static readonly geomActionSubject = new Subject<GeometryAction>();
private static readonly syncSliceSubject = new Subject<void>();

static get slicer(): BehaviorSubject<Slicer | null> {
return this.slicerSubject;
Expand Down
10 changes: 5 additions & 5 deletions ui/src/toolbox/GeometryController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ import {saveAs} from 'file-saver';

export class GeometryController {
private draw: CesiumDraw | undefined;
private toastPlaceholder: HTMLElement;
private readonly toastPlaceholder: HTMLElement;
private viewer: Viewer | null = null;
private unlistenEditPostRender: Event.RemoveCallback | undefined;
private geometriesDataSource: CustomDataSource;
private julianDate = new JulianDate();
private readonly unlistenEditPostRender: Event.RemoveCallback | undefined;
private readonly geometriesDataSource: CustomDataSource;
private readonly julianDate = new JulianDate();
private selectedArea: Entity | undefined;
private screenSpaceEventHandler: ScreenSpaceEventHandler | undefined;
private geometriesCounter: AreasCounter = {
Expand All @@ -60,7 +60,7 @@ export class GeometryController {
rectangle: 0,
polygon: 0
};
private noEdit: boolean;
private readonly noEdit: boolean;

constructor(geometriesDataSource: CustomDataSource, toastPlaceholder: HTMLElement, noEdit = false) {
this.geometriesDataSource = geometriesDataSource;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/toolbox/ngm-draw-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class NgmDrawSection extends LitElementI18n {
accessor hidden = true;
@state()
accessor lineInfo: DrawInfo | undefined;
private draw: CesiumDraw | undefined;
private readonly draw: CesiumDraw | undefined;
private drawGeometries = [
{label: () => i18next.t('tbx_add_point_btn_label'), type: 'point', icon: 'ngm-point-draw-icon'},
{label: () => i18next.t('tbx_add_line_btn_label'), type: 'line', icon: 'ngm-line-draw-icon'},
Expand Down
Loading

0 comments on commit ce32b47

Please sign in to comment.