Skip to content

Commit 1737d9d

Browse files
Merge pull request diffblue#528 from diffblue/cleanup/max-line-length
Extract max line length into a constant
2 parents e7e43da + 3016a8e commit 1737d9d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

env-model-generator/src/javaCode.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as _ from "lodash";
22

3+
const maxLineLength = 150;
4+
35
function indent(line: string): string { return line === "" ? "" : " " + line; }
46

57
export abstract class CodeElement {
@@ -46,7 +48,7 @@ export class FnCall extends CodeElement implements Expression {
4648
argInLines[argInLines.length - 1] += ",";
4749
}
4850
const oneLine = this.fnName + "(" + argsInLines.join(" ") + ")";
49-
if (oneLine.length < 80)
51+
if (oneLine.length < maxLineLength)
5052
return [ oneLine ];
5153
return [
5254
this.fnName + "(",
@@ -74,7 +76,7 @@ export class BraceInitialiser extends CodeElement implements Expression {
7476
argInLines[argInLines.length - 1] += ",";
7577
}
7678
const oneLine = this.typename + " { " + argsInLines.join(" ") + " }";
77-
if (oneLine.length < 80)
79+
if (oneLine.length < maxLineLength)
7880
return [ oneLine ];
7981
return [
8082
this.typename + " {",
@@ -138,7 +140,7 @@ export class Assignment extends CodeElement implements Statement {
138140
rhsInLines[rhsInLines.length - 1] += ";";
139141
if (rhsInLines.length === 1) {
140142
const oneLine = this.lhs + " = " + rhsInLines[0];
141-
if (oneLine.length < 100)
143+
if (oneLine.length < maxLineLength)
142144
return [ oneLine ];
143145
}
144146
return [
@@ -169,15 +171,15 @@ export class Declaration extends CodeElement implements Statement, Member {
169171
rhsInLines[rhsInLines.length - 1] += ";";
170172
const name = this.name + (rhsInLines.length === 0 ? ";" : " =");
171173
const oneLineLhs = `${this.modifiedType} ${name}`;
172-
if (oneLineLhs.length >= 80)
174+
if (oneLineLhs.length >= maxLineLength)
173175
return [
174176
this.modifiedType,
175177
indent(name),
176178
...rhsInLines.map((arg) => indent(indent(arg))),
177179
];
178180
if (rhsInLines.length <= 1) {
179181
const oneLine = rhsInLines.length === 0 ? oneLineLhs : `${oneLineLhs} ${rhsInLines[0]}`;
180-
if (oneLine.length < 80)
182+
if (oneLine.length < maxLineLength)
181183
return [ oneLine ];
182184
}
183185
return [
@@ -203,7 +205,7 @@ export class Return extends CodeElement implements Statement {
203205
valueInLines[valueInLines.length - 1] += ";";
204206
if (valueInLines.length === 1) {
205207
const oneLine = "return " + valueInLines[0];
206-
if (oneLine.length < 100)
208+
if (oneLine.length < maxLineLength)
207209
return [ oneLine ];
208210
}
209211
return [

0 commit comments

Comments
 (0)