Skip to content

Commit

Permalink
enhance AlignParametersRule etc. for lower maximum line length (SAP#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgrassau committed Dec 10, 2024
1 parent 9096805 commit 948e46e
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public abstract class Rule {
protected static Language[] ddlOrDcl = new Language[] { Language.DDL, Language.DCL };
protected static Language[] ddlOnly = new Language[] { Language.DDL };

/** the lowest value that can be configured for the 'maximum line length' in various rules for ABAP */
protected static final int MIN_LINE_LENGTH_ABAP = 60;
/** the default value for the 'maximum line length' configuration in various rules for ABAP */
protected static final int DEFAULT_LINE_LENGTH_ABAP = 120;
/** a higher default value for the 'maximum line length' configuration for ABAP */
protected static final int HIGHER_DEFAULT_LINE_LENGTH_ABAP = 130;
/** the highest default value for the 'maximum line length' configuration for ABAP */
protected static final int HIGHEST_DEFAULT_LINE_LENGTH_ABAP = 160;

/** the lowest value that can be configured for the 'maximum line length' in various rules for DDL */
protected static final int MIN_LINE_LENGTH_DDL = 60;
/** the default value for the 'maximum line length' configuration in various rules for DDL */
protected static final int DEFAULT_LINE_LENGTH_DDL = 120;

private static final String KEY_IS_ACTIVE = "isActive";
private static final String KEY_SETTING_COUNT = "settingCount";
private static final String KEY_SETTINGS = "settings";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String getExample() {
+ LINE_SEP + " ENDMETHOD.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);

final ConfigEnumValue<DistinctLineClear> configDistinctLineClear = new ConfigEnumValue<DistinctLineClear>(this, "DistinctLineClear", "CLEAR: Use one line per variable:",
new String[] { "always", "only if additions are used", "never", "keep as is" }, DistinctLineClear.values(), DistinctLineClear.ALWAYS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public String getExample() {
+ LINE_SEP + " ENDMETHOD.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners and tabular cases:", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners and tabular cases:", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);

final ConfigEnumValue<CondOneLinerStyle> configOneLinerStyle = new ConfigEnumValue<CondOneLinerStyle>(this, "OneLinerStyle", "One-liners:",
new String[] { "create if possible", "keep as is", "always split to multi-line" }, CondOneLinerStyle.values(), CondOneLinerStyle.KEEP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public String getExample() {
final ConfigEnumValue<StructureAlignStyle> configStructureAlignStyle = new ConfigEnumValue<StructureAlignStyle>(this, "StructureAlignStyle", "Scope of nested structures:", structureAlignStyleTexts, StructureAlignStyle.values(), StructureAlignStyle.PER_LEVEL, StructureAlignStyle.ACROSS_LEVELS, LocalDate.of(2023, 5, 21) );
final ConfigEnumValue<AlignEnumAction> configAlignEnumAction = new ConfigEnumValue<AlignEnumAction>(this, "AlignEnumAction", "Action for enums (BEGIN OF ENUM ...):", alignEnumActionTexts, AlignEnumAction.values(), AlignEnumAction.ALIGN_NAME_AND_VALUE, AlignEnumAction.ALIGN_NAME_ONLY, LocalDate.of(2023, 12, 30) );
final ConfigIntValue configFillPercentageToJustifyOwnColumn = new ConfigIntValue(this, "FillPercentageToJustifyOwnColumn", "Fill Ratio to justify own column", "%", 1, 20, 100);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "(only used to move VALUE clauses to the next line if required)", 80, 130, 255, 200, LocalDate.of(2023, 7, 28));
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "(only used to move VALUE clauses to the next line if required)", MIN_LINE_LENGTH_ABAP, HIGHER_DEFAULT_LINE_LENGTH_ABAP, 255, 200, LocalDate.of(2023, 7, 28));
final ConfigBoolValue configCondenseInnerSpaces = new ConfigBoolValue(this, "CondenseInnerSpaces", "Condense inner spaces in non-aligned parts", true, true, LocalDate.of(2023, 6, 10));

private final ConfigValue[] configValues = new ConfigValue[] { configExecuteOnClassDefAndInterfaces, configAlignChainAction, configAlignNonChainsAction, configAlignAcrossEmptyLines, configAlignAcrossCommentLines, configAlignStructureAction, configStructureAlignStyle, configAlignEnumAction, configMaxLineLength, configFillPercentageToJustifyOwnColumn, configCondenseInnerSpaces };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public String getExample() {
+ LINE_SEP + " ENDMETHOD.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length A (normal)", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLengthForSingleLine = new ConfigIntValue(this, "MaxLineLengthForSingleLine", "Maximum line length B (for tabular style)", "", 80, 160, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length A (normal)", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLengthForSingleLine = new ConfigIntValue(this, "MaxLineLengthForSingleLine", "Maximum line length B (for tabular style)", "", MIN_LINE_LENGTH_ABAP, HIGHEST_DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxParamCountBehindProceduralCall = new ConfigIntValue(this, "MaxParamCountBehindProceduralCall", "Procedural call: continue behind the call for up to", "parameters", 0, 0, 100);
final ConfigIntValue configMaxParamCountBehindFunctionalCall = new ConfigIntValue(this, "MaxParamCountBehindFunctionalCall", "Functional call: continue behind the call for up to", "parameters", 0, 100, 100);
final ConfigBoolValue configPutProceduralCallKeywordsOnOwnLine = new ConfigBoolValue(this, "PutProceduralCallKeywordsOnOwnLine", "Procedural call: put keywords (EXPORTING etc.) on own line", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public String getExample() {
+ LINE_SEP + "ENDFORM.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configParamCountAfterPerform = new ConfigIntValue(this, "ParamCountAfterPerform", "Continue behind PERFORM for up to", "parameters", 0, 3, 100);
final ConfigBoolValue configBreakAfterAdditions = new ConfigBoolValue(this, "BreakAfterAdditions", "Always break after call if additions IN PROGRAM or IF FOUND are used", false);
final ConfigBoolValue configAlignWithFormName = new ConfigBoolValue(this, "AlignWithFormName", "Align TABLES / USING / CHANGING with subroutine name", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public String getExample() {
+ LINE_SEP + " ENDMETHOD.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners:", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners:", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigEnumValue<SelectOneLinerAction> configMainQueryOneLinerAction = new ConfigEnumValue<SelectOneLinerAction>(this, "MainQueryOneLinerAction", "Mainquery one-liners:",
new String[] { "create if possible", "keep existing", "always split" }, SelectOneLinerAction.values(), SelectOneLinerAction.KEEP_EXISTING);
final ConfigEnumValue<SelectOneLinerAction> configSubQueryOneLinerAction = new ConfigEnumValue<SelectOneLinerAction>(this, "SubQueryOneLinerAction", "Subquery one-liners:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public String getExample() {
}

private final String[] layoutTexts = new String[] { "multi-line", "single line", "derive from majority", "keep as is" };
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigEnumValue<SelectListLayout> configComplexSelectListLayout = new ConfigEnumValue<SelectListLayout>(this, "ComplexSelectListLayout", "Select lists with complex fields:", layoutTexts, SelectListLayout.values(), SelectListLayout.MULTI_LINE);
final ConfigEnumValue<SelectListLayout> configSimpleSelectListLayout = new ConfigEnumValue<SelectListLayout>(this, "SimpleSelectListLayout", "Select lists with simple fields only:", layoutTexts, SelectListLayout.values(), SelectListLayout.DERIVE);
final ConfigEnumValue<SelectListLayout> configComplexGroupByListLayout = new ConfigEnumValue<SelectListLayout>(this, "ComplexGroupByListLayout", "GROUP BY lists with complex fields:", layoutTexts, SelectListLayout.values(), SelectListLayout.MULTI_LINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String getExample() {

private final String[] layoutTexts = new String[] { "multi-line", "single line", "derive from majority", "keep as is" };

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", 80, 120, DDL.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", MIN_LINE_LENGTH_DDL, DEFAULT_LINE_LENGTH_DDL, DDL.MAX_LINE_LENGTH);
final ConfigEnumValue<DdlNameListPos> configNameListPos = new ConfigEnumValue<DdlNameListPos>(this, "NameListPos", "Name list position:",
new String[] { "continue after view name", "below line start + 2", "below line start + 4", "below view name + 2", "below view name + 4", "keep as is" }, DdlNameListPos.values(), DdlNameListPos.LINE_START_PLUS_2);
final ConfigEnumValue<SelectListLayout> configNameListLayout = new ConfigEnumValue<SelectListLayout>(this, "NameListLayout", "Name lists layout:", layoutTexts, SelectListLayout.values(), SelectListLayout.MULTI_LINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public String getExample() {
final ConfigBoolValue configSpaceInsideBrackets = new ConfigBoolValue(this, "SpaceInsideBrackets", "Space inside array brackets [ ... ]", true);

private final ConfigInfoValue configInfoOneLiners = new ConfigInfoValue(this, "One-liners", ConfigInfoStyle.HEADING);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners", "", 80, 120, DDL.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length for one-liners", "", MIN_LINE_LENGTH_DDL, DEFAULT_LINE_LENGTH_DDL, DDL.MAX_LINE_LENGTH);
final ConfigIntValue configMaxOneLinerElemCountMain = new ConfigIntValue(this, "MaxOneLinerElemCountMain", "Max. number of elements for one-liners in entity annotations:", "", 1, 4, 10);
final ConfigIntValue configMaxOneLinerElemCountList = new ConfigIntValue(this, "MaxOneLinerElemCountList", "Max. number of elements for one-liners in select lists etc.:", "", 1, 4, 10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public String getExample() {
+ LINE_SEP + " cl_other_local_class.";
}

final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", 80, 120, ABAP.MAX_LINE_LENGTH);
final ConfigIntValue configMaxLineLength = new ConfigIntValue(this, "MaxLineLength", "Maximum line length", "", MIN_LINE_LENGTH_ABAP, DEFAULT_LINE_LENGTH_ABAP, ABAP.MAX_LINE_LENGTH);
final ConfigEnumValue<ClassDefIndentStyle> configIndentStyle = new ConfigEnumValue<ClassDefIndentStyle>(this, "IndentStyle", "Indentation:",
new String[] { "2 spaces", "4 spaces", "align with class name", "align with DEFINITION keyword" }, ClassDefIndentStyle.values(), ClassDefIndentStyle.PLUS_2);
final ConfigEnumValue<ClassDefOneLinerAction> configOneLinerAction = new ConfigEnumValue<ClassDefOneLinerAction>(this, "OneLinerAction", "One-/Two-liners:",
Expand Down

0 comments on commit 948e46e

Please sign in to comment.