File tree Expand file tree Collapse file tree 5 files changed +26
-6
lines changed Expand file tree Collapse file tree 5 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 88 "homepage" : " https://github.com/codeleague/codecoach" ,
99 "license" : " MIT" ,
1010 "scripts" : {
11- "lint" : " eslint ' src/**/*.{js,ts}' --quiet --fix" ,
12- "lint-ci" : " eslint ' src/**/*.{js,ts}' " ,
13- "format" : " prettier --write ' src/**/*.{js,ts}' " ,
11+ "lint" : " eslint \" src/**/*.{js,ts}\" --quiet --fix" ,
12+ "lint-ci" : " eslint \" src/**/*.{js,ts}\" " ,
13+ "format" : " prettier --write \" src/**/*.{js,ts}\" " ,
1414 "test" : " jest" ,
1515 "build" : " tsc --project tsconfig.build.json" ,
1616 "dev" : " nodemon --inspect=5858 --config ./nodemon.json -- --config=\" config-test.json\" " ,
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ describe('groupComments', () => {
9797 text :
9898 ':rotating_light: msg1' +
9999 ' \n' +
100- ':warning: (SUPPRESSED) additional warning' +
100+ ':warning: (SUPPRESSED) additional warning (rule: UNIMPORTANT_RULE2) ' +
101101 ' \n' ,
102102 } ,
103103 {
@@ -138,7 +138,7 @@ describe('groupComments', () => {
138138 text :
139139 ':rotating_light: msg1' +
140140 ' \n' +
141- ':warning: (SUPPRESSED) additional warning' +
141+ ':warning: (SUPPRESSED) additional warning (rule: UNIMPORTANT_RULE/RULE2) ' +
142142 ' \n' ,
143143 } ,
144144 {
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ function buildText(
4646 const { severity, msg } = item ;
4747 const { text : currentText } = currentComment ;
4848 const msgWithSuppression = isSuppressed ? `(SUPPRESSED) ${ msg } ` : msg ;
49- const text = MessageUtil . createMessageWithEmoji ( msgWithSuppression , severity ) ;
49+ const msgWithRuleId = MessageUtil . addRuleIdToMessage ( msgWithSuppression , item . ruleId ) ;
50+ const text = MessageUtil . createMessageWithEmoji ( msgWithRuleId , severity ) ;
5051 return `${ currentText } ${ text } \n` ;
5152}
5253
Original file line number Diff line number Diff line change @@ -26,3 +26,18 @@ describe('generateCommitDescription', () => {
2626 expect ( MessageUtil . generateCommitDescription ( 99 ) ) . toBe ( 'CodeCoach report 99 errors' ) ;
2727 } ) ;
2828} ) ;
29+
30+ describe ( 'addRuleIdToMessage' , ( ) => {
31+ it ( 'should add ruleId to message' , ( ) => {
32+ const msg = 'test' ;
33+ const ruleId = 'id' ;
34+
35+ expect ( MessageUtil . addRuleIdToMessage ( msg , ruleId ) ) . toBe ( `${ msg } (rule: ${ ruleId } )` ) ;
36+ } ) ;
37+ it ( 'should not add ruleId to message if ruleId is empty' , ( ) => {
38+ const msg = 'test' ;
39+ const ruleId = '' ;
40+
41+ expect ( MessageUtil . addRuleIdToMessage ( msg , ruleId ) ) . toBe ( msg ) ;
42+ } ) ;
43+ } ) ;
Original file line number Diff line number Diff line change @@ -46,4 +46,8 @@ ${warningMsg}`;
4646 ? `CodeCoach report ${ nOfErrors } errors`
4747 : 'CodeCoach report no critical issue, good job!' ;
4848 }
49+
50+ static addRuleIdToMessage ( msg : string , ruleId : string ) : string {
51+ return `${ msg } ` + ( ruleId ? ` (rule: ${ ruleId } )` : '' ) ;
52+ }
4953}
You can’t perform that action at this time.
0 commit comments