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

Checker should provide a better API #911

Open
Ducasse opened this issue Oct 31, 2024 · 0 comments
Open

Checker should provide a better API #911

Ducasse opened this issue Oct 31, 2024 · 0 comments

Comments

@Ducasse
Copy link
Contributor

Ducasse commented Oct 31, 2024

Currently we are using such kind of hack to produce the report of the command line.
This is clearly not good.

execute
	| file |
	file :=  self requestedFile asString asFileReference. 
	file exists 
		ifTrue: [ 
			| reporter  parent exampleChecker checker collector |
			parent := self project baseDirectory.

			reporter := MicAnalysisReportWriter new.
			checker := MicReferenceChecker new.
			checker fileSystem: parent.
			checker checkProject: file.

			reporter addResults: checker results.
			
			collector := MicFileCollector new.
			collector 
				rootDirectory: parent;
				visit: (Microdown parseFile: file).
			
			exampleChecker := MicCodeBlockValidator new.

			collector visitedFiles do: [ :each |
				exampleChecker start: each ].
			reporter addResults: exampleChecker results. 
				
			reporter isOkay
					ifTrue: [ 
						self outputStreamDo: 
									[ :str | str 
											cr;
											nextPutAll:  'File ' ; 
											nextPutAll: (self relativePathStringOf: file) ; 
											nextPutAll: ' does not have reference problems.' ]]
					ifFalse: [ 
						self outputStreamDo: 
									[ :str | 
										str 
											cr; 
											nextPutAll: 'File ' ; 
											nextPutAll: (self relativePathStringOf: file) ; 
											nextPutAll: ' has reference problems.'; cr.
										reporter buildReportOn: str ] ] ]
		ifFalse: [ 
				self outputStreamDo: [ :str | 
					str 
						cr; 
						nextPutAll: 'File ' ; 
						nextPutAll: file fullName ; 
						nextPutAll: ' does not exist.'  ] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant