@@ -594,35 +594,20 @@ static void replace(std::string& source, const std::unordered_map<std::string, s
594594 }
595595}
596596
597- static void replaceColors (std::string& source, bool enableColors) {
598- if (enableColors) {
599- static const std::unordered_map<std::string, std::string> substitutionMap =
600- {
601- {" {reset}" , ::toString (Color::Reset)},
602- {" {bold}" , ::toString (Color::Bold)},
603- {" {dim}" , ::toString (Color::Dim)},
604- {" {red}" , ::toString (Color::FgRed)},
605- {" {green}" , ::toString (Color::FgGreen)},
606- {" {blue}" , ::toString (Color::FgBlue)},
607- {" {magenta}" , ::toString (Color::FgMagenta)},
608- {" {default}" , ::toString (Color::FgDefault)},
609- };
610- replace (source, substitutionMap);
611- }
612- else {
613- static const std::unordered_map<std::string, std::string> substitutionMap =
614- {
615- {" {reset}" , " " },
616- {" {bold}" , " " },
617- {" {dim}" , " " },
618- {" {red}" , " " },
619- {" {green}" , " " },
620- {" {blue}" , " " },
621- {" {magenta}" , " " },
622- {" {default}" , " " },
623- };
624- replace (source, substitutionMap);
625- }
597+ static void replaceColors (std::string& source) {
598+ // TODO: colors are not applied when either stdout or stderr is not a TTY because we resolve them before the stream usage
599+ static const std::unordered_map<std::string, std::string> substitutionMap =
600+ {
601+ {" {reset}" , ::toString (Color::Reset)},
602+ {" {bold}" , ::toString (Color::Bold)},
603+ {" {dim}" , ::toString (Color::Dim)},
604+ {" {red}" , ::toString (Color::FgRed)},
605+ {" {green}" , ::toString (Color::FgGreen)},
606+ {" {blue}" , ::toString (Color::FgBlue)},
607+ {" {magenta}" , ::toString (Color::FgMagenta)},
608+ {" {default}" , ::toString (Color::FgDefault)},
609+ };
610+ replace (source, substitutionMap);
626611}
627612
628613std::string ErrorMessage::toString (bool verbose, const std::string &templateFormat, const std::string &templateLocation) const
@@ -928,16 +913,16 @@ std::string replaceStr(std::string s, const std::string &from, const std::string
928913 return s;
929914}
930915
931- void substituteTemplateFormatStatic (std::string& templateFormat, bool enableColors )
916+ void substituteTemplateFormatStatic (std::string& templateFormat)
932917{
933918 replaceSpecialChars (templateFormat);
934- replaceColors (templateFormat, enableColors );
919+ replaceColors (templateFormat);
935920}
936921
937- void substituteTemplateLocationStatic (std::string& templateLocation, bool enableColors )
922+ void substituteTemplateLocationStatic (std::string& templateLocation)
938923{
939924 replaceSpecialChars (templateLocation);
940- replaceColors (templateLocation, enableColors );
925+ replaceColors (templateLocation);
941926}
942927
943928std::string getClassification (const std::string &guideline, ReportType reportType) {
0 commit comments