Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NS_UNAVAILABLE flag to all unneeded super initializers (NSObject init) #477

Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions ObjectiveGit/GTBlame.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
/// A `GTBlame` provides authorship info, through `GTBlameHunk` for each line of a file. Analogous to `git_blame` in libgit2.
@interface GTBlame : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
///
/// blame - A git_blame to wrap. May not be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTBlame.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ @interface GTBlame ()

@implementation GTBlame

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitBlame:(git_blame *)blame {
NSParameterAssert(blame != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTBlameHunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
/// A `GTBlameHunk` is an object that provides authorship info for a set of lines in a `GTBlame`.
@interface GTBlameHunk : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
///
/// hunk - A git_blame_hunk to wrap. May not be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTBlameHunk.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

@implementation GTBlameHunk

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk {
self = [super init];
if (self == nil) return nil;
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTBranch.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)localNamePrefix;
+ (NSString *)remoteNamePrefix;

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
///
/// ref - The branch reference to wrap. Must not be nil.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ + (nullable instancetype)branchWithReference:(GTReference *)ref repository:(GTRe
return [[self alloc] initWithReference:ref repository:repo];
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo {
NSParameterAssert(ref != nil);
NSParameterAssert(repo != nil);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
/// repository, this will always be nil.
@property (nonatomic, readonly, copy, nullable) NSArray *remotes;

- (instancetype)init NS_UNAVAILABLE;

/// Creates and returns a configuration which includes the global, XDG, and
/// system configurations.
+ (nullable instancetype)defaultConfiguration;
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ - (void)dealloc {
}
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitConfig:(git_config *)config repository:(GTRepository *)repository {
NSParameterAssert(config != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ NS_ASSUME_NONNULL_BEGIN
/// Returns a newly created GTDiff, or nil if an error occurred.
+ (nullable instancetype)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repository options:(nullable NSDictionary *)options error:(NSError **)error;

- (instancetype)init NS_UNAVAILABLE;

/// Designated initialiser.
///
/// diff - The diff to represent. Cannot be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiff.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ + (instancetype)diffWorkingDirectoryToHEADInRepository:(GTRepository *)repositor
return HEADIndexDiff;
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitDiff:(git_diff *)diff repository:(GTRepository *)repository {
NSParameterAssert(diff != NULL);
NSParameterAssert(repository != nil);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiffDelta.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ NS_ASSUME_NONNULL_BEGIN
/// Returns a diff delta, or nil if an error occurs.
+ (nullable instancetype)diffDeltaFromData:(nullable NSData *)oldData forPath:(nullable NSString *)oldDataPath toData:(nullable NSData *)newData forPath:(nullable NSString *)newDataPath options:(nullable NSDictionary *)options error:(NSError **)error;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver to wrap the delta at the given index.
///
/// diff - The diff which contains the delta to wrap. Must not be nil.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiffDelta.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ + (instancetype)diffDeltaFromData:(NSData *)oldData forPath:(NSString *)oldDataP
}];
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithDiff:(GTDiff *)diff deltaIndex:(NSUInteger)deltaIndex {
NSCParameterAssert(diff != nil);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiffFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The git_diff_file represented by the receiver.
@property (nonatomic, readonly) git_diff_file git_diff_file;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver with the provided libgit2 object. Designated initializer.
///
/// file - The git_diff_file wrapped by the receiver.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiffFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

@implementation GTDiffFile

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitDiffFile:(git_diff_file)file {
NSParameterAssert(file.path != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiffHunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The number of lines represented in the hunk.
@property (nonatomic, readonly) NSUInteger lineCount;

- (instancetype)init NS_UNAVAILABLE;

/// Designated initialiser.
///
/// The contents of a hunk are lazily loaded, therefore we initialise the object
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiffHunk.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ @interface GTDiffHunk ()

@implementation GTDiffHunk

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithPatch:(GTDiffPatch *)patch hunkIndex:(NSUInteger)hunkIndex {
NSParameterAssert(patch != nil);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiffLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The number of newlines appearing in `-content`.
@property (nonatomic, readonly) NSInteger lineCount;

- (instancetype)init NS_UNAVAILABLE;

/// Designated initialiser.
///
/// line - The diff line to wrap. May not be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiffLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

@implementation GTDiffLine

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitLine:(const git_diff_line *)line {
self = [super init];
if (self == nil) return nil;
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTDiffPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The number of hunks in this patch.
@property (nonatomic, readonly) NSUInteger hunkCount;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver to wrap the given patch. Designated initializer.
///
/// patch - The patch object to wrap and take ownership of. This will
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTDiffPatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ @implementation GTDiffPatch

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitPatch:(git_patch *)patch delta:(GTDiffDelta *)delta {
NSParameterAssert(patch != NULL);
NSParameterAssert(delta != nil);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ NS_ASSUME_NONNULL_BEGIN
/// To set new options, use -resetWithOptions:.
@property (nonatomic, assign, readonly) GTEnumeratorOptions options;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver to enumerate the commits in the given repository. Designated initializer.
///
/// repo - The repository to enumerate the commits of. This must not be nil.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTEnumerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ @implementation GTEnumerator

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithRepository:(GTRepository *)repo error:(NSError **)error {
NSParameterAssert(repo != nil);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTFetchHeadEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
/// Flag indicating if we need to merge this entry or not.
@property (nonatomic, getter = isMerge, readonly) BOOL merge;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes a GTFetchHeadEntry. Designated initializer.
///
/// reference - Reference on the repository. Cannot be nil.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTFetchHeadEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

@implementation GTFetchHeadEntry

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithReference:(GTReference *)reference remoteURLString:(NSString *)remoteURLString targetOID:(GTOID *)targetOID isMerge:(BOOL)merge {
NSParameterAssert(reference != nil);
NSParameterAssert(remoteURLString != nil);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
/// chance to clean up the `payload`.
@property (nonatomic, copy) void (^cleanupBlock)(void *payload);

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the object with the given name and attributes. Designated initializer.
///
/// name - The name for the filter. Cannot be nil.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ + (void)initialize {
GTFiltersGitFilterToRegisteredFilters = [[NSMutableDictionary alloc] init];
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithName:(NSString *)name attributes:(NSString *)attributes applyBlock:(NSData * (^)(void **payload, NSData *from, GTFilterSource *source, BOOL *applied))applyBlock {
NSParameterAssert(name != nil);
NSParameterAssert(applyBlock != NULL);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTFilterList.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
/// An opaque list of filters that apply to a given path.
@interface GTFilterList : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver to wrap the given `git_filter_list`. Designated initializer.
///
/// filterList - The filter list to wrap and take ownership of. This filter list
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTFilterList.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ @implementation GTFilterList

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitFilterList:(git_filter_list *)filterList {
NSParameterAssert(filterList != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTFilterSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The filter mode.
@property (nonatomic, readonly, assign) GTFilterSourceMode mode;

- (instancetype)init NS_UNAVAILABLE;

/// Intializes the receiver with the given filter source. Designated initializer.
///
/// source - The filter source. Cannot be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTFilterSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ @implementation GTFilterSource

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitFilterSource:(const git_filter_source *)source {
NSParameterAssert(source != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ NS_ASSUME_NONNULL_BEGIN
/// Returns the loaded index, or nil if an error occurred.
+ (instancetype)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError **)error;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver with the given libgit2 index. Designated initializer.
///
/// index - The libgit2 index from which the index should be created. Cannot
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ + (instancetype)inMemoryIndexWithRepository:(GTRepository *)repository error:(NS
return [[self alloc] initWithGitIndex:index repository:repository];
}

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

+ (instancetype)indexWithFileURL:(NSURL *)fileURL repository:(GTRepository *)repository error:(NSError **)error {
NSParameterAssert(fileURL != nil);
NSParameterAssert(fileURL.isFileURL);
Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTIndexEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface GTIndexEntry : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver with the given libgit2 index entry.
///
/// entry - The libgit2 index entry. Cannot be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTIndexEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ - (NSString *)description {

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitIndexEntry:(const git_index_entry *)entry index:(GTIndex *)index error:(NSError **)error {
NSParameterAssert(entry != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTOID.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
/// inserted into the ODB yet.
@property (nonatomic, readonly, assign, getter = isZero) BOOL zero;

- (instancetype)init NS_UNAVAILABLE;

/// Initializes the receiver with the given git_oid. Designated initializer.
///
/// git_oid - The underlying git_oid. Cannot be NULL.
Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTOID.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ - (NSString *)SHA {

#pragma mark Lifecycle

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (instancetype)initWithGitOid:(const git_oid *)oid {
NSParameterAssert(oid != NULL);

Expand Down
2 changes: 2 additions & 0 deletions ObjectiveGit/GTObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, strong) GTRepository *repository;
@property (nonatomic, readonly, nullable) GTOID *OID;

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
- (nullable id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo NS_DESIGNATED_INITIALIZER;

Expand Down
5 changes: 5 additions & 0 deletions ObjectiveGit/GTObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ - (BOOL)isEqual:(id)otherObject {

#pragma mark API

- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}

- (id)initWithObj:(git_object *)object inRepository:(GTRepository *)repo {
NSParameterAssert(object != NULL);
NSParameterAssert(repo != nil);
Expand Down
Loading