Fixed various Codacy code style and logic issues

This commit is contained in:
cschwinne 2021-05-11 14:54:03 +02:00
parent 1ccc8eec0a
commit 5ca8bc3f2a
9 changed files with 15 additions and 13 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -19,14 +19,14 @@ uint16_t playlistEntryDur = 0;
void shufflePlaylist() {
int currentIndex = playlistLen, randomIndex;
int currentIndex = playlistLen;
PlaylistEntry temporaryValue, *entries = reinterpret_cast<PlaylistEntry*>(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];

View File

@ -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

View File

@ -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