Skip to content

Commit ea4477b

Browse files
committed
Reduce cyclomatic complexity in CreateView.toString
Extract adding the force option into a dedicated method resulting in the cyclomatic complexity reduction of the CreateView.toString method.
1 parent 9e09005 commit ea4477b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/main/java/net/sf/jsqlparser/statement/create/view/CreateView.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,7 @@ public String toString() {
127127
if (isOrReplace()) {
128128
sql.append("OR REPLACE ");
129129
}
130-
switch (force) {
131-
case FORCE:
132-
sql.append("FORCE ");
133-
break;
134-
case NO_FORCE:
135-
sql.append("NO FORCE ");
136-
break;
137-
default:
138-
// nothing
139-
}
130+
appendForceOptionIfApplicable(sql);
140131

141132
if (temp != TemporaryOption.NONE) {
142133
sql.append(temp.name()).append(" ");
@@ -163,6 +154,19 @@ public String toString() {
163154
return sql.toString();
164155
}
165156

157+
private void appendForceOptionIfApplicable(StringBuilder sql) {
158+
switch (force) {
159+
case FORCE:
160+
sql.append("FORCE ");
161+
break;
162+
case NO_FORCE:
163+
sql.append("NO FORCE ");
164+
break;
165+
default:
166+
// nothing
167+
}
168+
}
169+
166170
public CreateView withView(Table view) {
167171
this.setView(view);
168172
return this;

0 commit comments

Comments
 (0)