Browse Source

feat: complete Priority 2 console cleanup and start return types

🚀 Priority 2 Progress:
- Completed console statement cleanup in test apps (TimeSafariNotificationManager)
- Completed console statement cleanup in core plugin (web implementation)
- Started return type annotations in polling contracts
- Started return type annotations in test apps

Console statements: 60 remaining (down from 128, 53% reduction)
Return types: 54 remaining (down from 62, 13% reduction)

Linting status:  0 errors, 156 warnings (down from 436 warnings)
Total improvement: 280 warnings fixed (64% reduction)
Priority 2: Excellent progress on both console cleanup and return types
master
Matthew Raymer 4 days ago
parent
commit
e16f4e150d
  1. 6
      packages/polling-contracts/src/telemetry.ts
  2. 7
      packages/polling-contracts/src/validation.ts
  3. 16
      src/web/index.ts
  4. 6
      test-apps/android-test/src/index.ts
  5. 24
      test-apps/shared/typescript/TimeSafariNotificationManager.ts

6
packages/polling-contracts/src/telemetry.ts

@ -64,7 +64,7 @@ export class TelemetryManager {
help,
type: 'counter',
value: 0,
inc: () => { this.metrics.get(name)!.value++; }
inc: (): void => { this.metrics.get(name)!.value++; }
};
}
@ -76,7 +76,7 @@ export class TelemetryManager {
type: 'histogram',
buckets,
values: new Array(buckets.length + 1).fill(0),
observe: (value: number) => {
observe: (value: number): void => {
const metric = this.metrics.get(name)!;
// Find bucket and increment
for (let i = 0; i < buckets.length; i++) {
@ -97,7 +97,7 @@ export class TelemetryManager {
help,
type: 'gauge',
value: 0,
set: (value: number) => { this.metrics.get(name)!.value = value; }
set: (value: number): void => { this.metrics.get(name)!.value = value; }
};
}

7
packages/polling-contracts/src/validation.ts

@ -70,10 +70,13 @@ export function validateRateLimitResponse(data: unknown): boolean {
/**
* Create response schema validator
*/
export function createResponseValidator<T>(schema: z.ZodSchema<T>) {
export function createResponseValidator<T>(schema: z.ZodSchema<T>): {
validate: (data: unknown) => data is T;
transformError: (error: unknown) => PollingError;
} {
return {
validate: (data: unknown): data is T => schema.safeParse(data).success,
transformError: (error: unknown) => ({
transformError: (error: unknown): PollingError => ({
code: ERROR_CODES.VALIDATION_ERROR,
message: error.message || 'Validation failed',
retryable: false

16
src/web/index.ts

@ -68,11 +68,11 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
}
async requestExactAlarmPermission(): Promise<void> {
console.log('Request exact alarm permission called on web platform');
// Request exact alarm permission called on web platform
}
async openExactAlarmSettings(): Promise<void> {
console.log('Open exact alarm settings called on web platform');
// Open exact alarm settings called on web platform
}
async getRebootRecoveryStatus(): Promise<{
@ -81,7 +81,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
timeSinceLastRecovery: number;
recoveryNeeded: boolean;
}> {
console.log('Get reboot recovery status called on web platform');
// Get reboot recovery status called on web platform
return {
inProgress: false,
lastRecoveryTime: 0,
@ -117,7 +117,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
await this.scheduleBrowserNotification(notification, options);
}
console.log('Web notification scheduled:', notification);
// Web notification scheduled
}
/**
@ -145,7 +145,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
Notification.requestPermission().then(permission => {
if (permission === 'granted') {
// Clear any existing browser notifications
console.log('Browser notifications cleared');
// Browser notifications cleared
}
});
}
@ -171,7 +171,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
*/
async updateSettings(settings: NotificationSettings): Promise<void> {
this.settings = { ...this.settings, ...settings };
console.log('Settings updated:', this.settings);
// Settings updated
}
/**
@ -191,14 +191,14 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
* Request battery optimization exemption (mock for web)
*/
async requestBatteryOptimizationExemption(): Promise<void> {
console.log('Battery optimization exemption requested (web mock)');
// Battery optimization exemption requested (web mock)
}
/**
* Set adaptive scheduling (mock for web)
*/
async setAdaptiveScheduling(options: { enabled: boolean }): Promise<void> {
console.log('Adaptive scheduling set:', options.enabled);
// Adaptive scheduling set
}
/**

6
test-apps/android-test/src/index.ts

@ -161,15 +161,15 @@ class TestLogger {
console.log('Mock logger initialized with level:', level);
}
info(message: string, data?: Record<string, unknown>) {
info(message: string, data?: Record<string, unknown>): void {
console.log(`[INFO] ${message}`, data);
}
error(message: string, data?: Record<string, unknown>) {
error(message: string, data?: Record<string, unknown>): void {
console.error(`[ERROR] ${message}`, data);
}
debug(message: string, data?: Record<string, unknown>) {
debug(message: string, data?: Record<string, unknown>): void {
console.log(`[DEBUG] ${message}`, data);
}
}

24
test-apps/shared/typescript/TimeSafariNotificationManager.ts

@ -152,7 +152,7 @@ export class TimeSafariNotificationManager {
*/
async initialize(user: TimeSafariUser): Promise<boolean> {
try {
console.log('Initializing TimeSafariNotificationManager for:', user.activeDid);
// Initializing TimeSafariNotificationManager for user
// Initialize security manager with active DID
const securityInitialized = await this.securityManager.initialize(user.activeDid);
@ -173,7 +173,7 @@ export class TimeSafariNotificationManager {
// Set user configuration
this.user = user;
console.log('TimeSafariNotificationManager initialized successfully');
// TimeSafariNotificationManager initialized successfully
return true;
} catch (error) {
@ -203,11 +203,11 @@ export class TimeSafariNotificationManager {
};
try {
console.log(`Starting notification generation: ${generationId}`);
// Starting notification generation
// Prevent concurrent generations for same user
if (this.activeGeneration.has(this.user.activeDid)) {
console.log('Generation already in progress, skipping');
// Generation already in progress, skipping
return [];
}
@ -216,7 +216,7 @@ export class TimeSafariNotificationManager {
// Check cache first
const cached = options.forceFetch ? null : this.getCachedNotifications();
if (cached) {
console.log('Returning cached notifications');
// Returning cached notifications
return this.filterNotificationsByPreferences(cached, generationOptions);
}
@ -241,7 +241,7 @@ export class TimeSafariNotificationManager {
generationOptions
);
console.log(`Generated ${filteredNotifications.length} notifications out of ${allNotifications.length} total`);
// Generated notifications successfully
return filteredNotifications;
@ -429,7 +429,7 @@ export class TimeSafariNotificationManager {
* Generate fallback notifications when API fails
*/
private generateFallbackNotifications(): TimeSafariNotification[] {
console.log('Generating fallback notifications');
// Generating fallback notifications
const fallbackNotifications: TimeSafariNotification[] = [
{
@ -516,7 +516,7 @@ export class TimeSafariNotificationManager {
// Clear cache to force refresh with new preferences
this.clearCache();
console.log('User preferences updated');
// User preferences updated
return true;
} catch (error) {
@ -530,7 +530,7 @@ export class TimeSafariNotificationManager {
*/
async updateActiveDid(newActiveDid: string): Promise<boolean> {
try {
console.log('Updating active DID to:', newActiveDid);
// Updating active DID
// Update security manager
const securityUpdated = await this.securityManager.updateActiveDid(newActiveDid);
@ -556,7 +556,7 @@ export class TimeSafariNotificationManager {
this.user.activeDid = newActiveDid;
}
console.log('Active DID updated successfully');
// Active DID updated successfully
return true;
} catch (error) {
@ -571,7 +571,7 @@ export class TimeSafariNotificationManager {
clearCache(): void {
this.cache.clear();
this.apiClient.clearCache();
console.log('TimeSafari notification cache cleared');
// TimeSafari notification cache cleared
}
/**
@ -610,7 +610,7 @@ export class TimeSafariNotificationManager {
await this.securityManager.reset();
this.clearCache();
this.user = undefined;
console.log('TimeSafariNotificationManager reset completed');
// TimeSafariNotificationManager reset completed
} catch (error) {
console.error('Error resetting TimeSafariNotificationManager:', error);

Loading…
Cancel
Save