From af89e58a9cb9a022e963a91fe6e69baed99a1c64 Mon Sep 17 00:00:00 2001 From: relikd Date: Sat, 1 Oct 2022 17:37:37 +0200 Subject: [PATCH] fix: analyzer warnings on non-null value --- baRSS/Core Data/Feed+Ext.h | 2 +- baRSS/Core Data/Feed+Ext.m | 2 +- baRSS/Core Data/FeedGroup+Ext.h | 2 +- baRSS/Core Data/FeedGroup+Ext.m | 2 +- baRSS/Feed Import/Download3rdParty.h | 2 +- baRSS/Feed Import/Download3rdParty.m | 2 +- baRSS/Feed Import/FaviconDownload.h | 2 +- baRSS/Feed Import/FaviconDownload.m | 2 +- baRSS/Feed Import/FeedDownload.h | 2 +- baRSS/Feed Import/FeedDownload.m | 2 +- baRSS/Info.plist | 2 +- baRSS/NSCategories/NSDate+Ext.h | 2 +- baRSS/NSCategories/NSDate+Ext.m | 2 +- baRSS/NSCategories/NSView+Ext.h | 4 ++-- baRSS/NSCategories/NSView+Ext.m | 4 ++-- baRSS/Preferences/Feeds Tab/ModalFeedEdit.m | 2 +- baRSS/Status Bar Menu/NSMenu+Ext.h | 2 +- baRSS/Status Bar Menu/NSMenu+Ext.m | 2 +- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/baRSS/Core Data/Feed+Ext.h b/baRSS/Core Data/Feed+Ext.h index 60f4f84..2a40be4 100644 --- a/baRSS/Core Data/Feed+Ext.h +++ b/baRSS/Core Data/Feed+Ext.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)calculateAndSetIndexPathString; - (void)setNewIcon:(NSURL*)location; // Article properties -- (NSArray*)sortedArticles; +- (nullable NSArray*)sortedArticles; @end NS_ASSUME_NONNULL_END diff --git a/baRSS/Core Data/Feed+Ext.m b/baRSS/Core Data/Feed+Ext.m index ef62ad4..0b2a16f 100644 --- a/baRSS/Core Data/Feed+Ext.m +++ b/baRSS/Core Data/Feed+Ext.m @@ -124,7 +124,7 @@ /** @return Articles sorted by attribute @c sortIndex with descending order (newest items first). */ -- (NSArray*)sortedArticles { +- (nullable NSArray*)sortedArticles { if (self.articles.count == 0) return nil; return [self.articles sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:NO]]]; diff --git a/baRSS/Core Data/FeedGroup+Ext.h b/baRSS/Core Data/FeedGroup+Ext.h index 4662039..8fe41af 100644 --- a/baRSS/Core Data/FeedGroup+Ext.h +++ b/baRSS/Core Data/FeedGroup+Ext.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSMenuItem*)newMenuItem; // Handle children and parents - (NSString*)indexPathString; -- (NSArray*)sortedChildren; +- (nullable NSArray*)sortedChildren; - (NSMutableArray*)allParents; // Printing - (NSString*)readableDescription; diff --git a/baRSS/Core Data/FeedGroup+Ext.m b/baRSS/Core Data/FeedGroup+Ext.m index cfd689d..654310f 100644 --- a/baRSS/Core Data/FeedGroup+Ext.m +++ b/baRSS/Core Data/FeedGroup+Ext.m @@ -106,7 +106,7 @@ } /// @return Children sorted by attribute @c sortIndex (same order as in preferences). -- (NSArray*)sortedChildren { +- (nullable NSArray*)sortedChildren { if (self.children.count == 0) return nil; return [self.children sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]]; diff --git a/baRSS/Feed Import/Download3rdParty.h b/baRSS/Feed Import/Download3rdParty.h index 517833c..f5b9bf5 100644 --- a/baRSS/Feed Import/Download3rdParty.h +++ b/baRSS/Feed Import/Download3rdParty.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN // TODO: Make plugins extensible? community extensions. @interface YouTubePlugin : NSObject -+ (NSString*)feedURL:(NSURL*)url data:(NSData*)html; ++ (nullable NSString*)feedURL:(NSURL*)url data:(NSData*)html; + (NSString*)videoImage:(NSString*)videoid; + (NSString*)videoImageHQ:(NSString*)videoid; @end diff --git a/baRSS/Feed Import/Download3rdParty.m b/baRSS/Feed Import/Download3rdParty.m index 0b5d635..094a4ef 100644 --- a/baRSS/Feed Import/Download3rdParty.m +++ b/baRSS/Feed Import/Download3rdParty.m @@ -11,7 +11,7 @@ @return @c nil if @c url is not properly formatted, YouTube feed URL otherwise. */ -+ (NSString*)feedURL:(NSURL*)url data:(NSData*)html { ++ (nullable NSString*)feedURL:(NSURL*)url data:(NSData*)html { if (![url.host hasSuffix:@"youtube.com"]) // 'youtu.be' & 'youtube-nocookie.com' will redirect return nil; // https://www.youtube.com/channel/[channel-id] diff --git a/baRSS/Feed Import/FaviconDownload.h b/baRSS/Feed Import/FaviconDownload.h index 2a2d73f..b1060bb 100644 --- a/baRSS/Feed Import/FaviconDownload.h +++ b/baRSS/Feed Import/FaviconDownload.h @@ -16,7 +16,7 @@ typedef void(^FaviconDownloadBlock)(NSImage * _Nullable img, NSURL * _Nullable p - (instancetype)startWithBlock:(nonnull FaviconDownloadBlock)block; - (void)cancel; // Extract from HTML metadata -+ (nullable NSString*)urlForMetadata:(RSHTMLMetadata*)meta; ++ (nullable NSString*)urlForMetadata:(nullable RSHTMLMetadata*)meta; @end diff --git a/baRSS/Feed Import/FaviconDownload.m b/baRSS/Feed Import/FaviconDownload.m index 5c4e55b..8b6ce15 100644 --- a/baRSS/Feed Import/FaviconDownload.m +++ b/baRSS/Feed Import/FaviconDownload.m @@ -168,7 +168,7 @@ // --------------------------------------------------------------- /// Extract favicon URL from parsed HTML metadata. -+ (nullable NSString*)urlForMetadata:(RSHTMLMetadata*)meta { ++ (nullable NSString*)urlForMetadata:(nullable RSHTMLMetadata*)meta { if (!meta) return nil; double bestScore = DBL_MAX; diff --git a/baRSS/Feed Import/FeedDownload.h b/baRSS/Feed Import/FeedDownload.h index 080fb14..12ff206 100644 --- a/baRSS/Feed Import/FeedDownload.h +++ b/baRSS/Feed Import/FeedDownload.h @@ -35,7 +35,7 @@ typedef void (^FeedDownloadBlock)(FeedDownload *sender); @protocol FeedDownloadDelegate @optional /// Delegate must return chosen URL. If not implemented, the first URL will be used. -- (NSString*)feedDownload:(FeedDownload*)sender selectFeedFromList:(NSArray*)list; +- (nullable NSString*)feedDownload:(FeedDownload*)sender selectFeedFromList:(NSArray*)list; /// Only called if an URL redirect occured. - (void)feedDownload:(FeedDownload*)sender urlRedirected:(NSString*)newURL; /// Called after xml data is loaded and parsed. Called on error, but not if download is cancled. diff --git a/baRSS/Feed Import/FeedDownload.m b/baRSS/Feed Import/FeedDownload.m index 7b855d8..47866b3 100644 --- a/baRSS/Feed Import/FeedDownload.m +++ b/baRSS/Feed Import/FeedDownload.m @@ -168,7 +168,7 @@ self.error = [NSError canceledByUser]; } // finalize HTML parsing - if (self.error) { + if (self.error || !feedURL) { [self finishAndNotify]; } else { self.assertIsFeedURL = YES; diff --git a/baRSS/Info.plist b/baRSS/Info.plist index 3299162..45ae3f1 100644 --- a/baRSS/Info.plist +++ b/baRSS/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - 14690 + 14695 LSApplicationCategoryType public.app-category.news LSMinimumSystemVersion diff --git a/baRSS/NSCategories/NSDate+Ext.h b/baRSS/NSCategories/NSDate+Ext.h index b8a4231..72987e3 100644 --- a/baRSS/NSCategories/NSDate+Ext.h +++ b/baRSS/NSCategories/NSDate+Ext.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN @interface NSDate (Statistics) -+ (NSDictionary*)refreshIntervalStatistics:(NSArray *)list; ++ (nullable NSDictionary*)refreshIntervalStatistics:(NSArray *)list; @end NS_ASSUME_NONNULL_END diff --git a/baRSS/NSCategories/NSDate+Ext.m b/baRSS/NSCategories/NSDate+Ext.m index f04ed17..58ab144 100644 --- a/baRSS/NSCategories/NSDate+Ext.m +++ b/baRSS/NSCategories/NSDate+Ext.m @@ -140,7 +140,7 @@ static TimeUnitType const _values[] = { /** @return @c nil if list contains less than 2 entries. Otherwise: @{min, max, avg, median, earliest, latest} */ -+ (NSDictionary*)refreshIntervalStatistics:(NSArray *)list { ++ (nullable NSDictionary*)refreshIntervalStatistics:(NSArray *)list { if (!list || list.count == 0) return nil; diff --git a/baRSS/NSCategories/NSView+Ext.h b/baRSS/NSCategories/NSView+Ext.h index 28542e2..f2bef49 100644 --- a/baRSS/NSCategories/NSView+Ext.h +++ b/baRSS/NSCategories/NSView+Ext.h @@ -48,8 +48,8 @@ static inline CGFloat NSMaxWidth(NSView *a, NSView *b) { return Max(NSWidth(a.fr + (NSImageView*)imageView:(nullable NSImageName)name size:(CGFloat)size; + (NSButton*)checkbox:(BOOL)flag; + (NSProgressIndicator*)activitySpinner; -+ (NSView*)radioGroup:(NSArray*)entries target:(id)target action:(nonnull SEL)action; -+ (NSView*)radioGroup:(NSArray*)entries; ++ (nullable NSView*)radioGroup:(NSArray*)entries target:(id)target action:(nonnull SEL)action; ++ (nullable NSView*)radioGroup:(NSArray*)entries; // UI: Enclosing Container + (NSPopover*)popover:(NSSize)size; - (NSScrollView*)wrapContent:(NSView*)content inScrollView:(NSRect)rect; diff --git a/baRSS/NSCategories/NSView+Ext.m b/baRSS/NSCategories/NSView+Ext.m index d4f5066..dd6103e 100644 --- a/baRSS/NSCategories/NSView+Ext.m +++ b/baRSS/NSCategories/NSView+Ext.m @@ -126,7 +126,7 @@ } /// Create grouping view with vertically, left-aligned radio buttons. Action is identical for all buttons (grouping). -+ (NSView*)radioGroup:(NSArray*)entries target:(id)target action:(nonnull SEL)action { ++ (nullable NSView*)radioGroup:(NSArray*)entries target:(id)target action:(nonnull SEL)action { if (entries.count == 0) return nil; CGFloat w = 0, h = 0; @@ -145,7 +145,7 @@ } /// Same as @c radioGroup:target:action: but using dummy action to ignore radio button click events. -+ (NSView*)radioGroup:(NSArray*)entries { ++ (nullable NSView*)radioGroup:(NSArray*)entries { return [self radioGroup:entries target:self action:@selector(donothing)]; } diff --git a/baRSS/Preferences/Feeds Tab/ModalFeedEdit.m b/baRSS/Preferences/Feeds Tab/ModalFeedEdit.m index 16a6243..0ba7389 100644 --- a/baRSS/Preferences/Feeds Tab/ModalFeedEdit.m +++ b/baRSS/Preferences/Feeds Tab/ModalFeedEdit.m @@ -140,7 +140,7 @@ @return Either URL string or @c nil if user canceled the selection. */ -- (NSString*)feedDownload:(FeedDownload*)sender selectFeedFromList:(NSArray*)list { +- (nullable NSString*)feedDownload:(FeedDownload*)sender selectFeedFromList:(NSArray*)list { NSMenu *menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Choose feed menu", nil)]; menu.autoenablesItems = NO; for (RSHTMLMetadataFeedLink *fl in list) { diff --git a/baRSS/Status Bar Menu/NSMenu+Ext.h b/baRSS/Status Bar Menu/NSMenu+Ext.h index 6e292a3..d556944 100644 --- a/baRSS/Status Bar Menu/NSMenu+Ext.h +++ b/baRSS/Status Bar Menu/NSMenu+Ext.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)insertDefaultHeader; // Update menu - (void)setHeaderHasUnread:(BOOL)hasUnread hasRead:(BOOL)hasRead; -- (NSMenuItem*)deepestItemWithPath:(nonnull NSString*)path; +- (nullable NSMenuItem*)deepestItemWithPath:(nonnull NSString*)path; @end diff --git a/baRSS/Status Bar Menu/NSMenu+Ext.m b/baRSS/Status Bar Menu/NSMenu+Ext.m index c01fcb2..73a7384 100644 --- a/baRSS/Status Bar Menu/NSMenu+Ext.m +++ b/baRSS/Status Bar Menu/NSMenu+Ext.m @@ -116,7 +116,7 @@ typedef NS_ENUM(NSInteger, MenuItemTag) { @param path Dot separated list of @c sortIndex. E.g., @c Feed.indexPath. @return Either @c NSMenuItem that exactly matches @c path or one of the parent @c NSMenuItem if a submenu isn't open. */ -- (NSMenuItem*)deepestItemWithPath:(nonnull NSString*)path { +- (nullable NSMenuItem*)deepestItemWithPath:(nonnull NSString*)path { NSUInteger loc = [path rangeOfString:@"."].location; BOOL isLast = (loc == NSNotFound); NSString *indexStr = (isLast ? path : [path substringToIndex:loc]);