135
136 async performWork(config) {
137 let workItem = null;
138 switch (config.action) {139 case "opened":140 workItem = await this.createWorkItem(config);141 break;142 case "closed":143 workItem = await this.closeWorkItem(config);144 break;145 case "deleted":146 workItem = await this.deleteWorkItem(config);147 break;148 case "reopened":149 workItem = await this.reopenWorkItem(config);150 break;151 case "edited":152 workItem = await this.editWorkItem(config);153 break;154 case "labeled":155 workItem = await this.labelWorkItem(config);156 break;157 case "unlabeled":158 workItem = await this.unlabelWorkItem(config);159 break;160 case "assigned":161 workItem = await this.assignWorkItem(config);162 break;163 case "unassigned":164 workItem = await this.unassignWorkItem(config);165 break;166 case "created":167 workItem = await this.addComment(config);168 break;169 }170
171 if (!!config.schedule) {
172 await this.updateIssues(config);
Some code conventions require that all switch statements have a default case, even if the default case is empty. The idea is to always explicitly state what the default behavior should be so that it's clear that the developer didn't forget to handle the default fallback case.
switch (a) {
case 1:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}
switch (a) {
case 1:
/* code */
break;
// No Default
}