diff --git a/helpers/Dojo/AssignmentValidator.ts b/helpers/Dojo/AssignmentValidator.ts
index f9604ab38ee87a67bcc84c6fcc3edd05ca7f5cfe..c70e3cdedbcf58bee0ca3fe33b5e2c94e7c1d300 100644
--- a/helpers/Dojo/AssignmentValidator.ts
+++ b/helpers/Dojo/AssignmentValidator.ts
@@ -300,7 +300,7 @@ class AssignmentValidator {
                 this.newSubStep('SONAR_RUN', 'Run sonar analysis');
 
                 const runSuccess = SonarAnalyzer.runAnalysis(assignment.sonarKey, assignment.language, assignmentFile.buildLine);
-                if ( runSuccess ) {
+                if ( !runSuccess ) {
                     if ( !assignment.allowSonarFailure ) {
                         this.emitError(`Sonar gate failed`, 'Sonar analysis failure', AssignmentCheckerError.SONAR_ANALYSIS_FAILED);
                         return;