Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
id
}

suspend fun tryUpsync() = withContext(Dispatchers.IO) {

Check failure on line 77 in app/src/main/java/org/piramalswasthya/sakhi/repositories/MaaMeetingRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 24 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4lFE8rOzRbrIzaesdH&open=AZ4lFE8rOzRbrIzaesdH&pullRequest=455
val pending = dao.getBySyncState(SyncState.UNSYNCED)
if (pending.isEmpty()) return@withContext
pending.forEach { row ->
Expand Down Expand Up @@ -110,7 +110,20 @@
meetingImages = imagesParts
)
if (response.isSuccessful) {
dao.updateSyncState(row.id, SyncState.SYNCED)
val responseString = response.body()?.string()
if (!responseString.isNullOrBlank()) {
try {
val jsonObj = org.json.JSONObject(responseString)
val responseStatusCode = jsonObj.optInt("statusCode", -1)
if (responseStatusCode == 200) {
dao.updateSyncState(row.id, SyncState.SYNCED)
} else {
timber.log.Timber.e("MaaMeeting server rejected payload with status: $responseStatusCode")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check Timber import and usage patterns across the codebase

# Check for Timber imports
echo "=== Timber imports ==="
rg -n "import timber.log.Timber" --type=kotlin

# Check for Timber usage patterns
echo -e "\n=== Timber.e() usage (imported) ==="
rg -n "^\s*Timber\.e\(" --type=kotlin -A1

# Check for fully qualified Timber usage
echo -e "\n=== timber.log.Timber.e() usage (fully qualified) ==="
rg -n "timber\.log\.Timber\.e\(" --type=kotlin -A1

Repository: PSMRI/FLW-Mobile-App

Length of output: 50377


🏁 Script executed:

#!/bin/bash
# Check if MaaMeetingRepo.kt has Timber import and examine the reviewed lines
echo "=== MaaMeetingRepo.kt imports ==="
head -30 app/src/main/java/org/piramalswasthya/sakhi/repositories/MaaMeetingRepo.kt

echo -e "\n=== Lines around 121 in MaaMeetingRepo.kt ==="
sed -n '110,130p' app/src/main/java/org/piramalswasthya/sakhi/repositories/MaaMeetingRepo.kt

Repository: PSMRI/FLW-Mobile-App

Length of output: 2504


Add Timber import and use the standard import pattern consistent with the codebase.

The code uses the fully qualified name timber.log.Timber.e() instead of importing and using the standard Timber.e() pattern. Add import timber.log.Timber at the top of the file and replace both occurrences (lines 121 and 124) with Timber.e().

Also consider logging when the response body is null or blank after a successful HTTP response, since that case currently has no indication of the problem and leaves the sync state unchanged.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/org/piramalswasthya/sakhi/repositories/MaaMeetingRepo.kt`
at line 121, Replace the fully-qualified timber calls in MaaMeetingRepo with the
standard import by adding import timber.log.Timber at the top of the file and
change timber.log.Timber.e(...) to Timber.e(...) for the error logging
occurrences (the calls around the response handling in the method that processes
HTTP responses). Also add a defensive log when a successful HTTP response has a
null or blank body (in the same response-handling block) using Timber.e(...) to
report "empty response body" and include any response metadata so the sync state
can be diagnosed; keep the existing sync-state updates intact but ensure you log
the empty-body case so failures are visible.

}
} catch (e: Exception) {
timber.log.Timber.e("Failed to parse MaaMeeting response: $e")
}
}
}
}
}
Expand Down