Skip to content

Commit

Permalink
Chore/fix more sonarissues (#3888)
Browse files Browse the repository at this point in the history
* chore: Fix sonar issues

* chore: Fix sonar issues

---------
  • Loading branch information
ChristianHuehn authored Jan 20, 2025
1 parent 02d6719 commit 499c541
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ export class LoadInitialFileService {
}

private async handleErrorLoadFilesFromQueryParams(error: Error) {
if ((error as Error).message !== NO_FILES_LOADED_ERROR_MESSAGE) {
if (error.message !== NO_FILES_LOADED_ERROR_MESSAGE) {
const title = "File(s) could not be loaded from the given file URL parameter. Loaded sample files instead."
const message = this.createTitleUrlErrorDialog(error as Error)
const message = this.createTitleUrlErrorDialog(error)
this.showErrorDialog(title, message)
}
await this.loadSampleFiles()
Expand All @@ -170,9 +170,9 @@ export class LoadInitialFileService {
}

private async handleErrorLoadFilesFromIndexedDB(error: Error) {
if ((error as Error).message !== NO_FILES_LOADED_ERROR_MESSAGE) {
if (error.message !== NO_FILES_LOADED_ERROR_MESSAGE) {
const title = "Previously loaded files and settings could not be restored. Loaded sample files instead."
const message = (error as Error).message
const message = error.message
this.showErrorDialog(title, message)
}
await this.loadSampleFiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class GlobalConfigurationDialogComponent {
hideFlatBuildings$ = this.store.select(hideFlatBuildingsSelector)
resetCameraIfNewFileIsLoaded$ = this.store.select(resetCameraIfNewFileIsLoadedSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

handleResetCameraIfNewFileIsLoadedChanged(event: MatSlideToggleChange) {
this.store.dispatch(setResetCameraIfNewFileIsLoaded({ value: event.checked }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MapLayoutSelectionComponent {
layoutAlgorithm$ = this.store.select(layoutAlgorithmSelector)
maxTreeMapFiles$ = this.store.select(maxTreeMapFilesSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

handleSelectedLayoutAlgorithmChanged(event: { value: LayoutAlgorithm }) {
this.store.dispatch(setLayoutAlgorithm({ value: event.value }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ import { AsyncPipe } from "@angular/common"
export class HoveredNodePathPanelComponent {
hoveredNodePathPanelData$ = this.store.select(hoveredNodePathPanelDataSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class PresentationModeButtonComponent {

constructor(
private readonly store: Store<CcState>,
private elementReference: ElementRef
private readonly elementReference: ElementRef
) {}

setPresentationModeEnabled(event: MatSlideToggleChange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ import { AsyncPipe } from "@angular/common"
export class ToolBarComponent {
hoveredNodeId$ = this.store.select(hoveredNodeIdSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class UploadFilesService {
isUploading = false

constructor(
private store: Store,
private loadFileService: LoadFileService
private readonly store: Store,
private readonly loadFileService: LoadFileService
) {}

uploadFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ActionIconComponent } from "../../actionIcon/actionIcon.component"
imports: [ActionIconComponent]
})
export class UploadFilesButtonComponent {
constructor(private uploadFilesService: UploadFilesService) {}
constructor(private readonly uploadFilesService: UploadFilesService) {}

uploadFiles() {
this.uploadFilesService.uploadFiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ThreeMapControlsService } from "../../codeMap/threeViewer/threeMapContr
standalone: true
})
export class CenterMapButtonComponent {
constructor(private threeMapControlsService: ThreeMapControlsService) {}
constructor(private readonly threeMapControlsService: ThreeMapControlsService) {}

centerMap() {
this.threeMapControlsService.autoFitTo()
Expand Down
12 changes: 6 additions & 6 deletions visualization/app/codeCharta/ui/viewCube/viewCube.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class ViewCubeComponent implements OnInit {
private camera: PerspectiveCamera
private renderer: WebGLRenderer
private scene: Scene
private WIDTH = 200
private HEIGHT = 200
private LENGTH_VIEWCUBE = 1
private readonly WIDTH = 200
private readonly HEIGHT = 200
private readonly LENGTH_VIEWCUBE = 1

private hoverInfo = { cube: null, originalMaterial: null }

Expand All @@ -43,9 +43,9 @@ export class ViewCubeComponent implements OnInit {
}

constructor(
private elementReference: ElementRef,
private threeMapControlsService: ThreeMapControlsService,
private viewCubeMouseEvents: ViewCubeMouseEventsService
private readonly elementReference: ElementRef,
private readonly threeMapControlsService: ThreeMapControlsService,
private readonly viewCubeMouseEvents: ViewCubeMouseEventsService
) {}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ViewCubeEvents = {

@Injectable({ providedIn: "root" })
export class ViewCubeMouseEventsService {
private eventEmitter = new EventEmitter<ViewCubeEvents>()
private readonly eventEmitter = new EventEmitter<ViewCubeEvents>()

private cubeGroup: Group
private camera: PerspectiveCamera
Expand All @@ -25,7 +25,7 @@ export class ViewCubeMouseEventsService {
private controls: OrbitControls
private isDragging = false

constructor(private threeMapControlsService: ThreeMapControlsService) {}
constructor(private readonly threeMapControlsService: ThreeMapControlsService) {}

init(cubeGroup: Group, camera: PerspectiveCamera, renderer: WebGLRenderer) {
this.cubeGroup = cubeGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class ZoomSliderComponent implements OnInit {
minZoom: number

constructor(
private threeMapControlsService: ThreeMapControlsService,
private cdr: ChangeDetectorRef
private readonly threeMapControlsService: ThreeMapControlsService,
private readonly cdr: ChangeDetectorRef
) {}

ngOnInit() {
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/util/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type Listener<D = undefined> = (data?: D) => void
type AbstractEventMap = Record<string, Listener>

export class EventEmitter<EventMap extends AbstractEventMap> {
private listeners: Partial<Record<keyof EventMap, Listener[]>> = {}
private readonly listeners: Partial<Record<keyof EventMap, Listener[]>> = {}

on<EventType extends keyof EventMap>(event: EventType, callback: EventMap[EventType]) {
this.listeners[event] ??= []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class StreetLayoutGenerator {

return layoutNodes.map(streetLayoutNode => {
return StreetViewHelper.buildNodeFrom(
streetLayoutNode as CodeMapNode,
streetLayoutNode,
this.calculateHeightScale(map, treeMapSize, maxHeight),
maxHeight,
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class VerticalStreet extends Street {
protected leftRow: BoundingBox[] = []
protected rightRow: BoundingBox[] = []
orientation: VerticalOrientation
private _origin: Vector2

// biome-ignore lint/correctness/noUnusedVariables: <explanation>
constructor(node: CodeMapNode, children: BoundingBox[], depth: number, orientation: VerticalOrientation = VerticalOrientation.UP) {
super(node)
Expand Down
6 changes: 3 additions & 3 deletions visualization/app/codeCharta/util/color/colorConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import convert from "color-convert"
import { HSL } from "./hsl"

export class ColorConverter {
private static colorToVector3Map = new Map<string, Vector3>()
private static colorToVector3ArrayMap = new Map<string, number[]>()
private static hexToNumberMap = new Map<string, number>()
private static readonly colorToVector3Map = new Map<string, Vector3>()
private static readonly colorToVector3ArrayMap = new Map<string, number[]>()
private static readonly hexToNumberMap = new Map<string, number>()

static getVector3(color: string) {
let vector = this.colorToVector3Map.get(color)
Expand Down
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/util/color/hsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import convert from "color-convert"

export class HSL {
constructor(
private h: number,
private s: number,
private readonly h: number,
private readonly s: number,
private l: number
) {}

Expand Down
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/util/customConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const CUSTOM_CONFIGS_DOWNLOAD_FILE_VERSION = "1.0.1"
export const CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT = "CodeCharta::customConfigs"

export class CustomConfigHelper {
private static customConfigs: Map<string, CustomConfig> = CustomConfigHelper.loadCustomConfigsFromLocalStorage()
static customConfigChange$: BehaviorSubject<null> = new BehaviorSubject(null)
private static readonly customConfigs: Map<string, CustomConfig> = CustomConfigHelper.loadCustomConfigsFromLocalStorage()
public static readonly customConfigChange$: BehaviorSubject<null> = new BehaviorSubject(null)

static setCustomConfigsToLocalStorage() {
const newLocalStorageElement: LocalStorageCustomConfigs = {
Expand Down
4 changes: 1 addition & 3 deletions visualization/app/codeCharta/util/fileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ export function getCCFileAndDecorateFileChecksum(jsonInput: string | ExportWrapp

try {
const fileContent: ExportCCFile | ExportWrappedCCFile =
typeof jsonInput === "string"
? (JSON.parse(jsonInput) as ExportWrappedCCFile | ExportCCFile)
: (jsonInput as ExportWrappedCCFile | ExportCCFile)
typeof jsonInput === "string" ? (JSON.parse(jsonInput) as ExportWrappedCCFile | ExportCCFile) : jsonInput

if ("data" in fileContent && "checksum" in fileContent) {
mappedFile = fileContent.data
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/util/fileNameHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LoadFileService } from "../services/loadFile/loadFile.service"
const dateRegex = /_\d{4}(?:-\d{1,2}){2}_\d{1,2}-\d{1,2}\./

export class FileNameHelper {
private static JSON_EXTENSION = ".json"
private static readonly JSON_EXTENSION = ".json"

static getNewFileName(fileName: string, isDeltaState: boolean) {
return `${this.getFileNameWithoutTimestamp(fileName, isDeltaState)}_${this.getNewTimestamp()}`
Expand Down

0 comments on commit 499c541

Please sign in to comment.