Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable check for npath complexity #5267

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<suppress checks="MagicNumber" files=".*.java"/>
<suppress checks="ExplicitInitialization" files=".*.java"/>
<suppress checks="SuperClone" files=".*.java"/>
<suppress checks="NPathComplexity" files=".*.java"/>
<suppress checks="IllegalThrows" files=".*.java"/>
<suppress checks="IllegalThrows" files=".*.java"/>
<suppress checks="MissingDeprecated" files=".*.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,48 @@ public class MUITable extends UIBaseElement<MUITableAssert> implements HasAssert

@Override
public void setup(Field field) {
boolean isUI = FillFromAnnotationRules.fieldHasAnnotation(field, UI.class, MUITable.class);
boolean hasUI = FillFromAnnotationRules.fieldHasAnnotation(field, UI.class, MUITable.class);
if (!FillFromAnnotationRules.fieldHasAnnotation(field, JMUITable.class, MUITable.class)
&& !isUI) {
&& !hasUI) {
throw Exceptions.runtimeException(String.format("Table '%s' initialisation failed", core().getName()));
}
JMUITable j = field.getAnnotation(JMUITable.class);
Class<?> ui = JMUITable.class;
if (hasUI) {
setupFromUI(field);
} else {
setupFromJMUITable(field);
}
}

private void setupFromUI(Field field) {
Class<?> uiDefaults = JMUITable.class;
try {
base().setLocator(isUI ? field.getAnnotation(UI.class).value() : j.root());
rowLocator = isUI ? (String) ui.getDeclaredMethod("row").getDefaultValue() : j.row();
columnLocator = isUI ? (String) ui.getDeclaredMethod("cell").getDefaultValue() : j.cell();
columnMenuLocator = isUI ? (String) ui.getDeclaredMethod("columnMenu").getDefaultValue() : j.columnMenu();
scrollableElementLocator = isUI ? "" : j.scroll();
tableHeader = isUI ? new MUITableHeader((JMUITableHeader) ui.getDeclaredMethod("header").getDefaultValue())
: new MUITableHeader(j.header());
tableFooter = isUI ? new MUITableFooter((JMUITableFooter) ui.getDeclaredMethod("footer").getDefaultValue())
: new MUITableFooter(j.footer());
columnFilter = isUI ? new MUITableColumnFilter((JMUITableColumnFilter) ui.getDeclaredMethod("columnFilter").getDefaultValue())
: new MUITableColumnFilter(j.columnFilter());
columnConfig = isUI ? new MUITableColumnConfig((JMUITableColumnConfig) ui.getDeclaredMethod("columnConfig").getDefaultValue())
: new MUITableColumnConfig(j.columnConfig());
base().setLocator(field.getAnnotation(UI.class).value());
rowLocator = (String) uiDefaults.getDeclaredMethod("row").getDefaultValue();
columnLocator = (String) uiDefaults.getDeclaredMethod("cell").getDefaultValue();
columnMenuLocator = (String) uiDefaults.getDeclaredMethod("columnMenu").getDefaultValue();
scrollableElementLocator = "";
tableHeader = new MUITableHeader((JMUITableHeader) uiDefaults.getDeclaredMethod("header").getDefaultValue());
tableFooter = new MUITableFooter((JMUITableFooter) uiDefaults.getDeclaredMethod("footer").getDefaultValue());
columnFilter = new MUITableColumnFilter((JMUITableColumnFilter) uiDefaults.getDeclaredMethod("columnFilter").getDefaultValue());
columnConfig = new MUITableColumnConfig((JMUITableColumnConfig) uiDefaults.getDeclaredMethod("columnConfig").getDefaultValue());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

private void setupFromJMUITable(Field field) {
JMUITable j = field.getAnnotation(JMUITable.class);
base().setLocator(j.root());
rowLocator = j.row();
columnLocator = j.cell();
columnMenuLocator = j.columnMenu();
scrollableElementLocator = j.scroll();
tableHeader = new MUITableHeader(j.header());
tableFooter = new MUITableFooter(j.footer());
columnFilter = new MUITableColumnFilter(j.columnFilter());
columnConfig = new MUITableColumnConfig(j.columnConfig());
}

@JDIAction("Get '{name}' rows list")
public List<MUITableRow> rows() {
List<UIElement> rowList = core().finds(rowLocator).stream()
Expand Down
Loading