diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f62c5d15..7fc01749a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Builds after release 0.12.0 +#### Build 2105111 + +- Fixed various Codacy code style and logic issues + #### Build 2105110 - Added Usermod settings page and configurable usermods (PR #1951) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 53f5eb8e6..dcb372860 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1467,8 +1467,8 @@ uint16_t WS2812FX::mode_tricolor_fade(void) } byte stp = prog; // % 256 - uint32_t color = 0; for(uint16_t i = 0; i < SEGLEN; i++) { + uint32_t color; if (stage == 2) { color = color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), color2, stp); } else if (stage == 1) { diff --git a/wled00/file.cpp b/wled00/file.cpp index e3aac3ae0..90c0d629f 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -55,13 +55,12 @@ bool bufferedFind(const char *target, bool fromStart = true) { size_t targetLen = strlen(target); size_t index = 0; - uint16_t bufsize = 0, count = 0; byte buf[FS_BUFSIZE]; if (fromStart) f.seek(0); while (f.position() < f.size() -1) { - bufsize = f.read(buf, FS_BUFSIZE); - count = 0; + uint16_t bufsize = f.read(buf, FS_BUFSIZE); + uint16_t count = 0; while (count < bufsize) { if(buf[count] != target[index]) index = 0; // reset index if any char does not match diff --git a/wled00/json.cpp b/wled00/json.cpp index 718c1deb0..358253aa6 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -134,7 +134,7 @@ void deserializeSegment(JsonObject elem, byte it) if (icol.isNull()) break; byte sz = icol.size(); - if (sz == 0 && sz > 4) break; + if (sz == 0 || sz > 4) break; int rgbw[] = {0,0,0,0}; copyArray(icol, rgbw); diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index 3a3d8310e..449ad044b 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -112,7 +112,7 @@ void updateTimezone() { break; } case TZ_AUSTRALIA_NORTHERN : { - tcrStandard = {First, Sun, Apr, 3, 570}; //ACST = UTC + 9.5 hours + tcrDaylight = {First, Sun, Apr, 3, 570}; //ACST = UTC + 9.5 hours tcrStandard = tcrDaylight; break; } diff --git a/wled00/overlay.cpp b/wled00/overlay.cpp index cbb94c014..56d897cd1 100644 --- a/wled00/overlay.cpp +++ b/wled00/overlay.cpp @@ -63,10 +63,9 @@ void _overlayAnalogClock() } if (analogClock5MinuteMarks) { - int pix; - for (int i = 0; i <= 12; i++) + for (byte i = 0; i <= 12; i++) { - pix = analogClock12pixel + round((overlaySize / 12.0) *i); + int pix = analogClock12pixel + round((overlaySize / 12.0) *i); if (pix > overlayMax) pix -= overlaySize; strip.setPixelColor(pix, 0x00FFAA); } diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 885e1fb68..5a3b07999 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -19,14 +19,14 @@ uint16_t playlistEntryDur = 0; void shufflePlaylist() { - int currentIndex = playlistLen, randomIndex; + int currentIndex = playlistLen; PlaylistEntry temporaryValue, *entries = reinterpret_cast(playlistEntries); // While there remain elements to shuffle... while (currentIndex--) { // Pick a random element... - randomIndex = random(0, currentIndex); + int randomIndex = random(0, currentIndex); // And swap it with the current element. temporaryValue = entries[currentIndex]; entries[currentIndex] = entries[randomIndex]; diff --git a/wled00/set.cpp b/wled00/set.cpp index 9da329940..5f21f165a 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -124,7 +124,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) doInitBusses = true; } - ledCount = request->arg(F("LC")).toInt(); + t = request->arg(F("LC")).toInt(); if (t > 0 && t <= MAX_LEDS) ledCount = t; // upate other pins diff --git a/wled00/wled.h b/wled00/wled.h index 0d04f7717..964d88fa5 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2105110 +#define VERSION 2105111 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG