Skip to content

Commit

Permalink
#30 Replaced traditional for loops with enhanced for loops as pointed…
Browse files Browse the repository at this point in the history
… out by sonarqube
  • Loading branch information
shyzus committed Jun 16, 2024
1 parent 6af46b4 commit 46ed4b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions [email protected]/displayConfigState.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export class DisplayConfigState {
}

get builtin_monitor() {
for (let i = 0; i < this.monitors.length; i++) {
let monitor = this.monitors[i];
for (let monitor of this.monitors) {
if (monitor.is_builtin) {
return monitor;
}
Expand All @@ -58,8 +57,7 @@ export class DisplayConfigState {
}

get_monitor(connector) {
for (let i = 0; i < this.monitors.length; i++) {
let monitor = this.monitors[i];
for (let monitor of this.monitors) {
if (monitor.connector === connector) {
return monitor;
}
Expand All @@ -68,12 +66,10 @@ export class DisplayConfigState {
}

get_logical_monitor_for(connector) {
for (let i = 0; i < this.logical_monitors.length; i++) {
let lmonitor = this.logical_monitors[i];
for (let j = 0; j < lmonitor.monitors.length; j++) {
let lm_connector = lmonitor.monitors[j][0];
if (connector === lm_connector) {
return lmonitor;
for (let log_monitor of this.logical_monitors) {
for (let lm_monitor of log_monitor.monitors) {
if (connector === lm_monitor[0]) {
return log_monitor;
}
}
}
Expand All @@ -95,8 +91,8 @@ export class DisplayConfigState {
[]
];
let monitors = lmonitor_pack[5];
for (let i = 0; i < lmonitor.monitors.length; i++) {
let connector = lmonitor.monitors[i][0];
for (let log_monitor of lmonitor.monitors) {
let connector = log_monitor[0];
let monitor = this.get_monitor(connector);
monitors.push([
connector,
Expand Down
4 changes: 2 additions & 2 deletions [email protected]/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class Monitor {
this.connector = unpacked[0].unpack()[0].unpack();

let modes = unpacked[1].unpack();
for (let i = 0; i < modes.length; i++) {
let mode = modes[i].unpack();
for (let mode_idx in modes) {
let mode = modes[mode_idx].unpack();
let id = mode[0].unpack();
let mode_props = mode[6].unpack();
if ('is-current' in mode_props) {
Expand Down

0 comments on commit 46ed4b7

Please sign in to comment.