Oolite
Loading...
Searching...
No Matches
OOCheckPListSyntaxVerifierStage.m
Go to the documentation of this file.
1/*
2
3OOCheckPListSyntaxVerifierStage.m
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22MA 02110-1301, USA.
23
24*/
25
28
29#if OO_OXP_VERIFIER_ENABLED
30
32
33static NSString* const kStageName = @"Checking plist well-formedness";
34
36
37- (NSString*)name
38{
39 return kStageName;
40}
41
42- (BOOL)shouldRun
43{
44 return YES;
45}
46
47- (void)run
48{
49 OOFileScannerVerifierStage* fileScanner = nil;
50
51 fileScanner = [[self verifier] fileScannerStage];
52
53 NSArray* plists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"Config"];
54 NSArray* arrayPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigArrays"];
55 NSArray* dictionaryPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigDictionaries"];
56
57 NSString* plistName = nil;
58 foreach (plistName, plists) {
59 // don't scan a js file as a plist
60 if ([plistName isEqualToString:@"script.js"])
61 continue;
62
63 if ([fileScanner fileExists:plistName
64 inFolder:@"Config"
65 referencedFrom:nil
66 checkBuiltIn:NO]) {
67 OOLog(@"verifyOXP.syntaxCheck", @"Checking %@", plistName);
68 id retrieve = [fileScanner plistNamed:plistName
69 inFolder:@"Config"
71 checkBuiltIn:NO];
72 if (retrieve != nil) {
73 if ([retrieve isKindOfClass:[NSArray class]]) {
74 if (![arrayPlists containsObject:plistName]) {
75 OOLog(@"verifyOXP.syntaxCheck.error", @"%@ should be an array but isn't.", plistName);
76 }
77 } else if ([retrieve isKindOfClass:[NSDictionary class]]) {
78 if (![dictionaryPlists containsObject:plistName]) {
79 OOLog(@"verifyOXP.syntaxCheck.error", @"%@ should be an array but isn't.", plistName);
80 }
81 } else {
82 OOLog(@"verifyOXP.syntaxCheck.error", @"%@ is neither an array nor a dictionary.", plistName);
83 }
84 }
85 }
86 }
87}
88
89@end
90
91#endif
static NSString *const kStageName
#define OOLog(class, format,...)
Definition OOLogging.h:84
return nil
id plistNamed:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
OOOXPVerifier * verifier()
OOFileScannerVerifierStage * fileScannerStage()
NSDictionary * configurationDictionaryForKey:(NSString *key)