Skip to content

RAT-540: Create UI option collections#637

Open
Claudenw wants to merge 38 commits into
masterfrom
create-UIOptionCollections
Open

RAT-540: Create UI option collections#637
Claudenw wants to merge 38 commits into
masterfrom
create-UIOptionCollections

Conversation

@Claudenw
Copy link
Copy Markdown
Contributor

@Claudenw Claudenw commented Mar 22, 2026

Introduces ui package
Modifications to use ui package.

Changes of note:

  • AbstractOption becomes UIOption and is UI Specific.
  • Default values for parameters are moved into the UIOptionsCollection implementations.
  • HELP option is removed from Arg and left as implementation detail in UIOptionsCollections as there is not a common implementation across the UIs.
  • ui package is new and contains all the UI classes that will be used to create new UIs. In future PRs the Ant and Maven UIs will be extracted and placed in separate modules.
  • Many of the files are small changes to solve javadoc, checkstyle, or sonar issues that arise because of small changes to interfaces and low level method signatures.

Fix for RAT-540

@ottlinger ottlinger changed the title Create UI option collections RAT-540: Create UI option collections Mar 23, 2026
@Claudenw Claudenw force-pushed the create-UIOptionCollections branch from bf4e7b0 to e493553 Compare April 27, 2026 15:35
@Claudenw Claudenw marked this pull request as draft April 27, 2026 16:11
@Claudenw Claudenw force-pushed the create-UIOptionCollections branch from 37140e9 to b93bc7f Compare May 8, 2026 13:10
@Claudenw Claudenw marked this pull request as ready for review May 8, 2026 16:24
@Claudenw
Copy link
Copy Markdown
Contributor Author

@ottlinger, Once you finish this review I will rebase onto main to clean up the build errors.

try {
File includeFileName = context.getCommandLine().getParsedOptionValue(selected);
if (includeFileName != null) {
context.getConfiguration().addIncludedPatterns(ExclusionUtils.asIterable(includeFileName, "#"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description says "entries will be excluded from processing", but the method is "addIncludePatterns" - shouldn't it be "addExcludePatterns" then?

Most probably the description of the deprecated option is misleading ....



private static void doNotExecute(final ArgumentContext context, final Option selected) {
throw new ImplementationException(String.format("'%s' should not be executed directly", selected));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I wondered "... what to do instead" is missing in that message to the user of RAT.
If I get this message, did I do something wrong or not?

In the case of "help-licenses" I used the option correctly ....

context.getConfiguration().setStyleSheet(StyleSheets.getStyleSheet(style[0]));
}
private static void processOutputArgs(final ArgumentContext context, final UIOptionCollection<?> optionCollection) throws ConfigurationException {
for (Arg arg : new Arg[]{DRY_RUN, OUTPUT_FAMILIES, OUTPUT_LICENSES, OUTPUT_ARCHIVE, OUTPUT_STANDARD, OUTPUT_FILE, OUTPUT_STYLE}) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer List.of() due to better readability than arrays here ....

} catch (Exception e) {
throw ConfigurationException.from(e);
private static void processInputArgs(final ArgumentContext context, final UIOptionCollection<?> optionCollection) throws ConfigurationException {
for (Arg arg : new Arg[]{SOURCE, EXCLUDE, EXCLUDE_FILE, EXCLUDE_STD, EXCLUDE_PARSE_SCM, EXCLUDE_SIZE,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer List.of() due to better readability than arrays here ....

});
context.getConfiguration().setFrom(defaultBuilder.build());

for (Arg arg : new Arg[]{FAMILIES_APPROVED, FAMILIES_APPROVED_FILE, FAMILIES_DENIED, FAMILIES_DENIED_FILE,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer List.of() due to better readability than arrays here ....


import org.apache.rat.ui.UI;
import org.apache.rat.ui.UIOption;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a general description here that explains the proposed architecture?

}

@OptionCollectionTest.TestFunction
@Override
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class contains many unused (reported by IDE) methods - is that part of the changes or can these methods be removed?

<exclude>ALL</exclude>
</inputExcludeStds>
<inputIncludes>pom.xml</inputIncludes>
<inputExcludeStds>ALL</inputExcludeStds>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we document this breaking change in the change-notes for 1.0.0 explicitly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created RAT-556 as a reminder ticket

<configs>
<config>.rat/customConfig.xml</config>
</configs>
<inputExcludes>.rat/**</inputExcludes>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this configuration is "Maven-style" - would it make sense to ask over at the Maven mailing list?

plugins contains multiple plugin-entries .... that made me think about this breaking change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is: how does a configuration with multiple entries look like?

          <inputIncludes>
            <include>pom.xml</include>
            <include>foo.bar/include>
          </inputIncludes>

OR will it become

          <inputIncludes>pom.xml</inputIncludes>
          <inputIncludes>foo.bar</inputIncludes>

}

private AntDocumentation(final File outputDir) {
/* Visible for testing */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class contains unused methods:

  • writeTitle
  • writePara
  • writeList

Should they be removed or will they be needed later and are only yet unused?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I recall, this class and methods will be used in the Ant UI package.

I wouldn't worry too much about tools as it goes away at the end of this trasformation.

In the end we will have the following modules

  • core: (the core functionality)
  • core test: test code from core packaged with dependencies to make it easier for UI modules. Basically a maven module that points to core /src/test for its /src/main. Jars built like this include dependencies so that when included as test libraries the transitive dependencies are present.
  • CLI: the current command line interface
  • ANT: the ANT interface and components from tools that are used for it.
  • Maven: the Maven interface and the components from tools that are used for it.
  • packaging: -- Not sure about this one, but I think that it just puts outputs from the above modules into release (as in upload to sonatype or github release style) packages and deploys them.

The UI modules CLI, ANT, and Maven will have multiple sub modules. Something like

UI module pom

  • tools: Tooling from current tool module + additional bits.
  • main: The actual code that is released. Module should build the packaging necessary to use the UI as a stand alone unit

@Claudenw
Copy link
Copy Markdown
Contributor Author

@ottlinger you have a number of good questions and ideas here with respect to how this works going forward. I like the idea of describing how the architecture works. Would you rather I fix/comment on the issues in this PR (and potentially make it larger) or open another PR to add the documentation.

I had planned on writing/updating the general documentation (.md files) when this change is complete.

@ottlinger
Copy link
Copy Markdown
Contributor

ottlinger commented May 26, 2026

@Claudenw I created RAT-557 to add documentation and have a new PR for it. The Maven/configuration stuff should be handled here I guess.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants