Skip to content

Commit 3753a1b

Browse files
authored
Merge pull request #31 from GabinL21/clean-checker
Clean Citezen-Checking
2 parents 41b39a3 + 0f3541b commit 3753a1b

File tree

8 files changed

+31
-17
lines changed

8 files changed

+31
-17
lines changed

src/Citezen-Checking.package/CZChecker.class/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ It will check:
1717
It allows to specifie some rules (e.g. tell that the key has to be a 7-character-long word) with the messages addRule: aBlock and addRule: aBlock named: aString.
1818
A rule is a block with one parameter: a CZEntry.
1919

20-
You can check your file with these 3 lines:
20+
You can check your file with these 2 lines:
2121
checker := CZChecker new.
2222
checker checkFile: '/Users/.../file.bib'.
23-
checker checks.
23+
2424
If you compute it with "print it", you'll see the errors.
2525
If you don't print it, you can do at anytime by doing "print it" on that:
2626
checker errorString.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
interface
22
addRule: aCZRule
3-
aCZRule isNil
4-
ifFalse: [ rules add: aCZRule ]
3+
aCZRule ifNotNil: [ rules add: aCZRule ]

src/Citezen-Checking.package/CZChecker.class/instance/checkDuplicateField..st

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ as yet unclassified
22
checkDuplicateField: aCZField
33
(fieldKeys includes: aCZField key)
44
ifTrue: [
5-
errorStream nextPutAll: 'Warning: Removes duplicate field: ', aCZField key; cr.
5+
errorStream
6+
nextPutAll: 'Warning: Removes duplicate field: ';
7+
nextPutAll: aCZField key;
8+
cr.
69
^ false ].
710

811
fieldKeys add: aCZField key.

src/Citezen-Checking.package/CZChecker.class/instance/checkEmptyField..st

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ as yet unclassified
22
checkEmptyField: aCZField
33
(aCZField value = '')
44
ifTrue: [
5-
errorStream nextPutAll: 'Warning: Removes empty field: ', aCZField key; cr.
5+
errorStream
6+
nextPutAll: 'Warning: Removes empty field: ';
7+
nextPutAll: aCZField key;
8+
cr.
69
^ false ].
710

811
^ true

src/Citezen-Checking.package/CZChecker.class/instance/checkFile..st

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ checkFile: aString
99

1010
errorStream := WriteStream on: String new.
1111
[eof] whileFalse: [ self bibtexBlockToCZEntry: self getBibtexBlock ].
12-
self halt.
1312
^ self checks

src/Citezen-Checking.package/CZChecker.class/instance/checkMacroReferenced..st

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ checkMacroReferenced: aCZField
1818
macroSymbols do: [ :each |
1919
(macroKeys includes: each)
2020
ifFalse: [
21-
errorStream nextPutAll: 'Warning: Removes field: ', aCZField key, ' references this undefined macro: ', each; cr.
21+
errorStream
22+
nextPutAll: 'Warning: Removes field: ';
23+
nextPutAll: aCZField key;
24+
nextPutAll: ' references this undefined macro: ';
25+
nextPutAll: each;
26+
cr.
2227
error := true ] ].
2328

2429
^ error not

src/Citezen-Checking.package/CZChecker.class/instance/checks.st

+13-8
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,27 @@ checks
5959
toBeInclude := false ].
6060

6161
"checks if the key is unique and changes it if it's not"
62-
"keys at: entry key put: ((keys at: entry key ifAbsent: 0) + 1).
62+
keys at: entry key put: ((keys at: entry key ifAbsent: 0) + 1).
6363
((keys at: entry key) > 1)
6464
ifTrue: [ | key |
6565
key := entry key.
6666
entry key: '###',(entry key, '_',(keys at: entry key) asString,'###' ).
67-
errorStream nextPutAll: 'Warning: duplicate key: ', key, ' changed to: ', entry key; cr.
68-
error := true ]."
67+
errorStream
68+
nextPutAll: 'Warning: duplicate key: ';
69+
nextPutAll: key;
70+
nextPutAll: ' changed to: ';
71+
nextPutAll: entry key;
72+
cr.
73+
error := true ].
6974

7075
"checks if the entry respects all the rules"
7176
rules do: [ :rule |
72-
"(rule value value: entry)"
7377
(rule check: entry)
7478
ifFalse: [
75-
errorStream nextPutAll: 'Error : entry does not respect the rule: ', rule explanation; cr.
79+
errorStream
80+
nextPutAll: 'Error : entry does not respect the rule: ';
81+
nextPutAll: rule explanation;
82+
cr.
7683
error := true.
7784
toBeInclude := false ] ].
7885

@@ -84,9 +91,7 @@ checks
8491
nextPut: Character tab;
8592
nextPutAll: 'for :';
8693
cr;
87-
nextPutAll: "assoc value; "
88-
89-
"(CZBibtexOutputer new entryToBibtexString:" entry ")";
94+
nextPutAll: entry;
9095
cr.
9196
].
9297
toBeInclude

src/Citezen-Checking.package/CZChecker.class/properties.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"commentStamp" : "<historical>",
2+
"commentStamp" : "GabinLaigle 12/2/2022 15:21",
33
"super" : "Object",
44
"category" : "Citezen-Checking",
55
"classinstvars" : [ ],

0 commit comments

Comments
 (0)