Skip to content

Issue #3530: allowed ant to override and swap checker#3750

Merged
romani merged 1 commit into
checkstyle:masterfrom
rnveach:issue_3530
Jan 28, 2017
Merged

Issue #3530: allowed ant to override and swap checker#3750
romani merged 1 commit into
checkstyle:masterfrom
rnveach:issue_3530

Conversation

@rnveach

@rnveach rnveach commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

Issue #3530

setClassLoader is used by eclipse-cs.

setClassLoader - has weird javadoc that show some references to multifile validation that removed as problematic (we will come back to multifile mode later).

setClassLoader had to be moved to root module as ant wanted to set it.
Originally ant used contextualize to set the class loaders but the root module didn't support that method either. So the choice was to add the contextualize method via also adding the interface Contextualizable or just add the setter. I figured setter would be better as the interface would require all root modules to implement a complex method like contextualize. Main also used the setter methods instead of contextualize.

Added a reset method to TestRootModuleChecker to ensure it is false before any testing since the field is static.

@codecov-io

codecov-io commented Jan 23, 2017

Copy link
Copy Markdown

Current coverage is 100% (diff: 100%)

Merging #3750 into master will not change coverage

@@           master   #3750   diff @@
=====================================
  Files         275     275          
  Lines       13608   13609     +1   
  Methods         0       0          
  Messages        0       0          
  Branches     3062    3063     +1   
=====================================
+ Hits        13608   13609     +1   
  Misses          0       0          
  Partials        0       0          

Powered by Codecov. Last update 4cff2eb...0bac0af

@romani

romani commented Jan 28, 2017

Copy link
Copy Markdown
Member

example that classLoader is for loading other classes, not a Checker itself.

    /** Class loader to resolve classes with. **/
    private ClassLoader classLoader = Thread.currentThread()
            .getContextClassLoader();

    /**
     * Sets the classloader that is used to contextualize fileset checks.
     * Some Check implementations will use that classloader to improve the
     * quality of their reports, e.g. to load a class and then analyze it via
     * reflection.
     * @param classLoader the new classloader
     */
    public final void setClassLoader(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

vs

    /** The classloader used for loading Checkstyle module classes. */
    private ClassLoader moduleClassLoader;

Checker.setClassLoader is required only for JavadocMethodCheck (by mean of AbstractTypeAwareCheck) both classes are deprecated.
If we remove Checker.setClassLoader, we will damage work of JavadocMethodCheck class so we should remove this method only after we re-implement this Check.

So it mean that introduction of new API method only in satisfy deprecated functionality is NOT OK.

@romani

romani commented Jan 28, 2017

Copy link
Copy Markdown
Member

@rnveach , see comment above, so it is not ok to change API to support deprecated functionality.
It is not OK to allow any other RootModule to think that classLoader is required.

classLoader is optional.
It will exists in Checker (default RootModule) till we reimplement JavadocMethodCheck to use grammar.

For now, I recommend to do a workaround in our ANT task to check name of RootModule and if it is Checker do cast and do setClassLoader. So we will support JavadocMethodCheck only in Checker.
If user do like this, he need to make its own AntTask class.

@romani romani merged commit 785ed05 into checkstyle:master Jan 28, 2017
@rnveach rnveach deleted the issue_3530 branch January 29, 2017 00:15
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.

3 participants