Skip to content

Commit 0bf8916

Browse files
author
jarulraj
committed
Added a hint mode
- giving usage hints instead of classifying as anti-patterns
1 parent 4d2b389 commit 0bf8916

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/checker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ void Check(Configuration& state) {
7575
}
7676
else {
7777
std::cout << "\n==================== Summary ===================\n";
78-
std::cout << "All Anti-Patterns :: " << state.checker_stats[RISK_LEVEL_ALL] << "\n";
78+
std::cout << "All Anti-Patterns and Hints :: " << state.checker_stats[RISK_LEVEL_ALL] << "\n";
7979
std::cout << "> High Risk :: " << state.checker_stats[RISK_LEVEL_HIGH] << "\n";
8080
std::cout << "> Medium Risk :: " << state.checker_stats[RISK_LEVEL_MEDIUM] << "\n";
8181
std::cout << "> Low Risk :: " << state.checker_stats[RISK_LEVEL_LOW] << "\n";
82+
std::cout << "> Hints :: " << state.checker_stats[RISK_LEVEL_NONE] << "\n";
8283
}
8384

8485
// Skip destroying std::cin

src/configuration.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ std::string RiskLevelToString(const RiskLevel& risk_level){
3535
return "MEDIUM RISK";
3636
case RISK_LEVEL_LOW:
3737
return "LOW RISK";
38+
case RISK_LEVEL_NONE:
39+
return "HINTS";
3840
case RISK_LEVEL_ALL:
3941
return "ALL ANTI-PATTERNS";
4042

@@ -53,7 +55,9 @@ std::string RiskLevelToDetailedString(const RiskLevel& risk_level){
5355
case RISK_LEVEL_MEDIUM:
5456
return "ONLY MEDIUM AND HIGH RISK ANTI-PATTERNS";
5557
case RISK_LEVEL_LOW:
56-
return "ALL ANTI-PATTERNS";
58+
return "ONLY ANTI-PATTERNS";
59+
case RISK_LEVEL_NONE:
60+
return "ALL ANTI-PATTERNS AND HINTS";
5761
case RISK_LEVEL_ALL:
5862
return "ALL ANTI-PATTERNS";
5963

src/include/configuration.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ namespace sqlcheck {
1919
enum RiskLevel {
2020
RISK_LEVEL_INVALID = 10,
2121

22-
RISK_LEVEL_HIGH = 3,
23-
RISK_LEVEL_MEDIUM = 2,
24-
RISK_LEVEL_LOW = 1,
22+
RISK_LEVEL_HIGH = 4,
23+
RISK_LEVEL_MEDIUM = 3,
24+
RISK_LEVEL_LOW = 2,
25+
RISK_LEVEL_NONE = 1,
2526
RISK_LEVEL_ALL = 0
2627

2728
};

src/list.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void CheckNullUsage(Configuration& state,
599599
sql_statement,
600600
print_statement,
601601
pattern,
602-
RISK_LEVEL_LOW,
602+
RISK_LEVEL_NONE,
603603
pattern_type,
604604
title,
605605
message,
@@ -630,7 +630,7 @@ void CheckNotNullUsage(Configuration& state,
630630
sql_statement,
631631
print_statement,
632632
pattern,
633-
RISK_LEVEL_MEDIUM,
633+
RISK_LEVEL_NONE,
634634
pattern_type,
635635
title,
636636
message,

0 commit comments

Comments
 (0)