Skip to content

Commit

Permalink
chore: Add more readonlys, rename interfaces and remove unused returns
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-huehn-mw authored and IhsenBouallegue committed Jan 17, 2025
1 parent 83311e0 commit ffe8a40
Show file tree
Hide file tree
Showing 34 changed files with 68 additions and 71 deletions.
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/codeCharta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class CodeChartaComponent implements OnInit {
isInitialized = false

constructor(
private store: Store,
private loadInitialFileService: LoadInitialFileService
private readonly store: Store,
private readonly loadInitialFileService: LoadInitialFileService
) {}

async ngOnInit(): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions visualization/app/codeCharta/codeCharta.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface FileCount {
changed: number
}

interface squarifiedNode {
interface SquarifiedNode {
name: string
id?: number
type: NodeType
Expand All @@ -64,12 +64,12 @@ interface squarifiedNode {
fileCount?: FileCount
}

interface streetNode {
interface StreetNode {
value?: number
rect?: Rectangle
zOffset?: number
}
export interface CodeMapNode extends squarifiedNode, streetNode {}
export interface CodeMapNode extends SquarifiedNode, StreetNode {}

export interface FixedPosition {
left: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CustomVisibilityMesh } from "../customVisibilityMesh"
export class BackPrintContainerMesh extends GeneralMesh implements GeneralSizeChangeMesh {
private childrenMeshes: Map<string, GeneralMesh>

constructor(private font: Font) {
constructor(private readonly font: Font) {
const colorChangeStrategy = new BackPrintColorChangeStrategy()
super("BackPrintContainer", colorChangeStrategy)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { GeometryOptions } from "../../preview3DPrintMesh"
import { CustomVisibilityMesh } from "../customVisibilityMesh"

export class CodeChartaLogoMesh extends CustomVisibilityMesh {
private createSvgStrategy: CreateSvgGeometryStrategy
private readonly createSvgStrategy: CreateSvgGeometryStrategy

constructor(name: string, createSvgStrategy: CreateSvgGeometryStrategy = new CreateSvgGeometryStrategy()) {
constructor(name: string,
createSvgStrategy: CreateSvgGeometryStrategy = new CreateSvgGeometryStrategy()) {
super(name, new BackPrintColorChangeStrategy(), 180, true)
this.createSvgStrategy = createSvgStrategy
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MetricDescriptionBlockMesh extends CustomVisibilityMesh {
constructor(
public metricDescriptionBlockOptions: MetricDescriptionBlockOptions,
public font: Font,
private yOffset: number
private readonly yOffset: number
) {
super(metricDescriptionBlockOptions.name, new BackPrintColorChangeStrategy(), 200, true)
this.createSvgGeometryStrategy = new CreateSvgGeometryStrategy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GeneralSizeChangeMesh } from "../generalMesh"
export class CustomLogoMesh extends FrontLogo implements GeneralSizeChangeMesh {
constructor(
name: string,
private filePath: string
private readonly filePath: string
) {
super(name, "left")
}
Expand Down Expand Up @@ -50,6 +50,5 @@ export class CustomLogoMesh extends FrontLogo implements GeneralSizeChangeMesh {

changeSize(geometryOptions: GeometryOptions, oldWidth: number): void {
this.position.x -= (geometryOptions.width - oldWidth) / 2
return
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FrontPrintColorChangeStrategy } from "../../ColorChangeStrategies/front
export abstract class FrontLogo extends GeneralMesh {
constructor(
name: string,
private alignment: "right" | "left"
private readonly alignment: "right" | "left"
) {
super(name, new FrontPrintColorChangeStrategy())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ export class FrontMWLogoMesh extends FrontLogo implements GeneralSizeChangeMesh

changeSize(geometryOptions: GeometryOptions, oldWidth: number): void {
this.position.x += (geometryOptions.width - oldWidth) / 2
return
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FrontLogo } from "./frontLogo"
export class FrontPrintContainerMesh extends GeneralMesh implements GeneralSizeChangeMesh {
private childrenMeshes: Map<string, GeneralMesh>

constructor(private font: Font) {
constructor(private readonly font: Font) {
const colorChangeStrategy = new BackPrintColorChangeStrategy()
super("FrontPrintContainer", colorChangeStrategy)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ShaderMaterial } from "three"
import { BaseplateColorChangeStrategy } from "../ColorChangeStrategies/baseplateColorChangeStrategy"

export class BaseplateMesh extends GeneralMesh implements GeneralSizeChangeMesh {
constructor(private createBaseplateGeometryStrategy: CreateBaseplateGeometryStrategy = new CreateBaseplateGeometryStrategy()) {
constructor(private readonly createBaseplateGeometryStrategy: CreateBaseplateGeometryStrategy = new CreateBaseplateGeometryStrategy()) {
super("Baseplate", new BaseplateColorChangeStrategy())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export class MapMesh extends CustomVisibilityMesh {
async changeSize(geometryOptions: GeometryOptions, oldWidth: number): Promise<void> {
const scale = (geometryOptions.width - 2 * geometryOptions.mapSideOffset) / (oldWidth - 2 * geometryOptions.mapSideOffset)
this.geometry.scale(scale, scale, scale)
return
}

updateColor(numberOfColors: number) {
this.updateMapColors(this.originalColors, this.geometry, numberOfColors)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class TextMesh extends CustomVisibilityMesh {
minScale: number,
manualVisibility: boolean,
public createTextGeometryOptions: CreateTextGeometryStrategyOptions,
private createTextGeometryStrategy = new CreateTextGeometryStrategy()
private readonly createTextGeometryStrategy = new CreateTextGeometryStrategy()
) {
super(name, colorChangeStrategy, minScale, manualVisibility)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export interface GeometryOptions {
}

export class Preview3DPrintMesh {
private printMesh: Mesh
private readonly printMesh: Mesh
private currentSize: Vector3

constructor(
private geometryOptions: GeometryOptions,
private readonly geometryOptions: GeometryOptions,
private frontPrintContainerMesh: FrontPrintContainerMesh = new FrontPrintContainerMesh(new Font(font)),
private backPrintContainerMesh: BackPrintContainerMesh = new BackPrintContainerMesh(new Font(font)),
private baseplateMesh: BaseplateMesh = new BaseplateMesh(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ function constructVertices(
vertexIndexToNewVertexIndex.set(vertexIndex, vertexToNewVertexIndex.get(vertexString))
}
}

return
}

function constructTriangles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export class LoadFileService implements OnDestroy {
.subscribe()

constructor(
private store: Store<CcState>,
private state: State<CcState>,
private dialog: MatDialog
private readonly store: Store<CcState>,
private readonly state: State<CcState>,
private readonly dialog: MatDialog
) {}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const sampleFile2 = { fileName: "sample2.cc.json", fileSize: 2 * 1024, co

@Injectable({ providedIn: "root" })
export class LoadInitialFileService {
private urlUtils = new UrlExtractor(this.httpClient)
private readonly urlUtils = new UrlExtractor(this.httpClient)

constructor(
private readonly store: Store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ExportCCFile, ExportWrappedCCFile } from "../../codeCharta.api.model"
import { ungzip } from "pako"

export class UrlExtractor {
constructor(private httpClient: HttpClient) {}
constructor(private readonly httpClient: HttpClient) {}

getParameterByName(name: string) {
const sanitizedName = name.replaceAll(/[[\]]/g, "\\$&")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { CcState } from "../../../codeCharta.model"
@Injectable()
export class AddBlacklistItemsIfNotResultsInEmptyMapEffect {
constructor(
private actions$: Actions,
private store: Store<CcState>,
private dialog: MatDialog
private readonly actions$: Actions,
private readonly store: Store<CcState>,
private readonly dialog: MatDialog
) {}

doBlacklistItemsResultInEmptyMap$ = this.actions$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { heightMetricSelector } from "../../store/dynamicSettings/heightMetric/h

@Injectable()
export class LinkColorMetricToHeightMetricEffect {
constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

linkHeightAndColorMetric$ = createEffect(() =>
combineLatest([this.store.select(heightMetricSelector), this.store.select(isColorMetricLinkedToHeightMetricSelector)]).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class HighlightButtonsComponent implements OnChanges {
isHighlighted: boolean

constructor(
private threeSceneService: ThreeSceneService,
private idToBuilding: IdToBuildingService
private readonly threeSceneService: ThreeSceneService,
private readonly idToBuilding: IdToBuildingService
) {}

ngOnChanges(changes: SimpleChanges): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class NodeContextMenuService {
private overlayReference: OverlayRef | null = null

constructor(
private overlay: Overlay,
private store: Store
private readonly overlay: Overlay,
private readonly store: Store
) {}

open(x: number, y: number) {
Expand Down Expand Up @@ -59,15 +59,15 @@ export class NodeContextMenuService {
}
}

private onLeftClickHideNodeContextMenu = (mouseEvent: MouseEvent) => {
private readonly onLeftClickHideNodeContextMenu = (mouseEvent: MouseEvent) => {
if (this.isEventFromColorPicker(mouseEvent)) {
return
}

this.close()
}

private onRightClickHideNodeContextMenu = event => {
private readonly onRightClickHideNodeContextMenu = event => {
if (event.button !== 2) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { tap } from "rxjs"
@Injectable()
export class OpenNodeContextMenuEffect {
constructor(
private actions$: Actions,
private nodeContextMenu: NodeContextMenuService
private readonly actions$: Actions,
private readonly nodeContextMenu: NodeContextMenuService
) {}

openNodeContextMenu$ = createEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class RenderCodeMapEffect {
private readonly codeMapRenderService: CodeMapRenderService
) {}

private actionsRequiringRender$ = this.actions$.pipe(ofType(...actionsRequiringRerender))
private readonly actionsRequiringRender$ = this.actions$.pipe(ofType(...actionsRequiringRerender))

renderCodeMap$ = createEffect(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { setHoveredNodeId } from "../../store/appStatus/hoveredNodeId/hoveredNod
@Injectable()
export class SaveCcStateEffect {
constructor(
private actions$: Actions,
private state: State<CcState>
private readonly actions$: Actions,
private readonly state: State<CcState>
) {}

saveCcState$ = createEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { visibleFileStatesSelector } from "../../selectors/visibleFileStates/vis
@Injectable()
export class SetLoadingIndicatorEffect {
constructor(
private actions$: Actions,
private store: Store<CcState>
private readonly actions$: Actions,
private readonly store: Store<CcState>
) {}

setIsLoadingFile$ = createEffect(() => this.store.select(visibleFileStatesSelector).pipe(map(() => setIsLoadingFile({ value: true }))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { State, Store } from "@ngrx/store"
@Injectable()
export class UpdateFileSettingsEffect {
constructor(
private store: Store<CcState>,
private state: State<CcState>
private readonly store: Store<CcState>,
private readonly state: State<CcState>
) {}

updateFileSettings$ = createEffect(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { colorMetricSelector } from "../../store/dynamicSettings/colorMetric/col
@Injectable()
export class UpdateMapColorsEffect {
constructor(
private store: Store<CcState>,
private state: State<CcState>
private readonly store: Store<CcState>,
private readonly state: State<CcState>
) {}

updateMapColors$ = createEffect(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export enum MetricQueryParemter {
@Injectable()
export class UpdateQueryParametersEffect {
constructor(
private loadInitialFileService: LoadInitialFileService,
private actions$: Actions,
private state: State<CcState>,
private store: Store<CcState>
private readonly loadInitialFileService: LoadInitialFileService,
private readonly actions$: Actions,
private readonly state: State<CcState>,
private readonly store: Store<CcState>
) {}

saveMetricsInQueryParameters$ = createEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { CcState } from "../../../codeCharta.model"
@Injectable()
export class UpdateVisibleTopLabelsEffect {
constructor(
private store: Store<CcState>,
private state: State<CcState>
private readonly store: Store<CcState>,
private readonly state: State<CcState>
) {}

updateVisibleTopLabels$ = createEffect(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { visibleFileStatesSelector } from "../../../selectors/visibleFileStates/
@Injectable()
export class ResetColorRangeEffect {
constructor(
private actions$: Actions,
private store: Store<CcState>
private readonly actions$: Actions,
private readonly store: Store<CcState>
) {}

resetColorRange$ = createEffect(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export class AttributeSideBarComponent {

constructor(
public isAttributeSideBarVisibleService: IsAttributeSideBarVisibleService,
private store: Store<CcState>
private readonly store: Store<CcState>
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { edgeVisibilitySelector } from "./utils/edgeVisibility.selector"
@Injectable({ providedIn: "root" })
export class CodeMapArrowService implements OnDestroy {
private map: Map<string, Node>
private VERTICES_PER_LINE = 5
private readonly VERTICES_PER_LINE = 5
private arrows: Object3D[] = new Array<Object3D>()
private HIGHLIGHT_BUILDING_DELAY = 1
private debounceCalculation: (hoveredBuilding: CodeMapBuilding) => void = debounce(
private readonly HIGHLIGHT_BUILDING_DELAY = 1
private readonly debounceCalculation: (hoveredBuilding: CodeMapBuilding) => void = debounce(
(hoveredBuilding: CodeMapBuilding) => this.resetEdgesOfBuildings(hoveredBuilding),
this.HIGHLIGHT_BUILDING_DELAY
)
private subscription = this.store
private readonly subscription = this.store
.select(hoveredNodeIdSelector)
.pipe(
tap(hoveredNodeId => {
Expand Down
Loading

0 comments on commit ffe8a40

Please sign in to comment.