GithubHelp home page GithubHelp logo

walkmod / walkmod-core Goto Github PK

View Code? Open in Web Editor NEW
152.0 9.0 23.0 792 KB

walkmod: an open source tool to fix coding style issues

Home Page: http://www.walkmod.com

License: GNU Lesser General Public License v3.0

Java 99.78% Groovy 0.22%
static-code-analysis java conventions fixer technical-debt

walkmod-core's Introduction

Build Status Windows Build Status

walkmod: To Fix Java Static Coding Analysis Issues

WalkMod, is an open source tool to share and apply code conventions by automatic quick fixes for coding style issues.

WalkMod is language agnostic and platform agnostic, since it can be extended to support multiple programming languages and runs in any platform, since it is coded in Java. However, the only current supported programming language is Java.

WalkMod began as an open source framework to run code transformations. It benefits directly from the experience accumulated over several years of large-scale projects to support multiple quick fixes for existing static code analysis tools.

WalkMod logo

Getting started

Docker can be installed either on your computer or in any CI tool to ensure your code style before merging changes. To get started, check out the installation instructions in the documentation.

Usage examples

WalkMod can be used to run short-lived commands or by using an static configuration.

You can find a list of real-world examples in the documentation.

Under the hood

Under the hood, WalkMod is built on the following components:

  • The ivy engine to download plugins from Maven repositories.
  • The Spring Framework to support IoC.

Contributing to WalkMod

Want to hack on WalkMod? Awesome! The org.walkmod.WalkmodFacade can help you to invoke the available commands by API.

If you want to hack on this, fork it, improve it and send me a pull request.

To get started using it, just clone it and call mvn install.

walkmod-core's People

Contributors

abelsromero avatar cal101 avatar dependabot[bot] avatar octopatch avatar rpau avatar rubenaranamorera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

walkmod-core's Issues

Unresolved dependency: org.walkmod#walkmod-findbugs-plugin

Hello,

Please help me to resolve the below issue :

:: loading settings :: url = jar:file:/D:/Applns/walkmod-3.0.0/lib/ivy-2.4.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: org.walkmod#walkmod-imports-cleaner-plugin-caller;working
        confs: [default]
        found org.walkmod#walkmod-imports-cleaner-plugin;2.0.3 in maven2
        [2.0.3] org.walkmod#walkmod-imports-cleaner-plugin;[2.0.0, 3.0.0)
        found org.walkmod#javalang;3.2.0 in maven2
        [3.2.0] org.walkmod#javalang;[3.0.0, 4.0.0)
        found org.walkmod#merger;1.0.1 in maven2
        [1.0.1] org.walkmod#merger;[1.0.1, 2.0)
        found org.walkmod#walkmod-sonar-plugin;1.2.2 in maven2
        [1.2.2] org.walkmod#walkmod-sonar-plugin;latest.integration
        found org.walkmod#javalang-compiler;2.3.7 in maven2
        [2.3.7] org.walkmod#javalang-compiler;[2.2, 3.0)
        found org.walkmod#javalang;4.8.7 in maven2
        [4.8.7] org.walkmod#javalang;[4.1.0, 5.0.0)
        found org.walkmod#model-checker;1.1 in maven2
        [1.1] org.walkmod#model-checker;[1.0, 2.0)
        found log4j#log4j;1.2.16 in maven2
        found org.walkmod#walkmod-refactor-plugin;2.3.3 in maven2
        [2.3.3] org.walkmod#walkmod-refactor-plugin;[2.3.3,3.0.0)
        found com.mashape.unirest#unirest-java;1.4.9 in maven2
        found org.apache.httpcomponents#httpclient;4.5.2 in maven2
        found org.apache.httpcomponents#httpcore;4.4.4 in maven2
        found commons-logging#commons-logging;1.2 in maven2
        found commons-codec#commons-codec;1.9 in maven2
        found org.apache.httpcomponents#httpasyncclient;4.1.1 in maven2
        found org.apache.httpcomponents#httpcore-nio;4.4.4 in maven2
        found org.apache.httpcomponents#httpmime;4.5.2 in maven2
        found org.json#json;20160212 in maven2
        found org.walkmod#walkmod-checkstyle-plugin;1.0.5 in maven2
        [1.0.5] org.walkmod#walkmod-checkstyle-plugin;latest.integration
        found org.walkmod#javalang;4.8.7 in maven2
        [4.8.7] org.walkmod#javalang;[4.5.0, 5.0)
        found org.walkmod#walkmod-dead-code-cleaner-plugin;1.3.3 in maven2
        [1.3.3] org.walkmod#walkmod-dead-code-cleaner-plugin;latest.integration
        found org.walkmod#walkmod-comments-cleaner-plugin;1.0.1 in maven2
        [1.0.1] org.walkmod#walkmod-comments-cleaner-plugin;latest.integration
        found org.walkmod#walkmod-javalang-plugin;3.0.5 in maven2
        [3.0.5] org.walkmod#walkmod-javalang-plugin;[2.0, 4.0)
        found org.walkmod#javalang;4.8.7 in maven2
        [4.8.7] org.walkmod#javalang;[3.1.0, 5.0.0)
        found com.squareup#javapoet;1.8.0 in maven2
        found org.walkmod#javalang-compiler;2.3.7 in maven2
        [2.3.7] org.walkmod#javalang-compiler;[2.0.0, 3.0.0)
:: resolution report :: resolve 12644ms :: artifacts dl 20ms
        :: evicted modules:
        org.walkmod#javalang;3.2.0 by [org.walkmod#javalang;4.8.7] in [default]
        org.walkmod#javalang-compiler;[2.0, 3.0) by [org.walkmod#javalang-compiler;2.3.7] in [default]
        org.apache.httpcomponents#httpclient;4.5.1 by [org.apache.httpcomponents#httpclient;4.5.2] in [default]
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      default     |   26  |   8   |   0   |   3   ||   34  |   0   |
        ---------------------------------------------------------------------

:: problems summary ::
:::: WARNINGS
                module not found: org.walkmod#walkmod-findbugs-plugin;latest.integration

        ==== maven2: tried

          http://repo1.maven.org/maven2/org/walkmod/walkmod-findbugs-plugin/[revision]/walkmod-findbugs-plugin-[revision].pom

          -- artifact org.walkmod#walkmod-findbugs-plugin;latest.integration!walkmod-findbugs-plugin.jar:

          http://repo1.maven.org/maven2/org/walkmod/walkmod-findbugs-plugin/[revision]/walkmod-findbugs-plugin-[revision].jar

                ::::::::::::::::::::::::::::::::::::::::::::::

                ::          UNRESOLVED DEPENDENCIES         ::

                ::::::::::::::::::::::::::::::::::::::::::::::

                :: org.walkmod#walkmod-findbugs-plugin;latest.integration: not found

                ::::::::::::::::::::::::::::::::::::::::::::::



:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
 WARN [main] - unresolved dependency: org.walkmod#walkmod-findbugs-plugin;latest.integration: not found
ERROR [main] - Invalid configuration
org.walkmod.conf.ConfigurationException: Ivy can not resolve the artifacts. Cause: unresolved dependency: org.walkmod#walkmod-findbugs-plugin;latest.integration: not found
        at org.walkmod.conf.providers.IvyConfigurationProvider.resolveArtifacts(IvyConfigurationProvider.java:233)
        at org.walkmod.conf.providers.IvyConfigurationProvider.load(IvyConfigurationProvider.java:156)
        at org.walkmod.conf.ConfigurationManager.executeConfigurationProviders(ConfigurationManager.java:124)
        at org.walkmod.conf.ConfigurationManager.addProviders(ConfigurationManager.java:61)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:75)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:79)
        at org.walkmod.WalkModFacade.readConfig(WalkModFacade.java:181)
        at org.walkmod.WalkModFacade.run(WalkModFacade.java:256)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:42)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
ERROR [main] - Invalid configuration
java.lang.NullPointerException
        at org.walkmod.WalkModFacade.run(WalkModFacade.java:264)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:42)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
Exception in thread "main" java.lang.NullPointerException
        at org.walkmod.WalkModFacade.run(WalkModFacade.java:284)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:42)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)

sonar:RemoveUselessVariables is not working

Steps to reproduce -

  1. Open cmd prompt > go to project directory > type command and press enter key > walkmod apply sonar:RemoveUselessVariables

  2. Project has a sample Java class for removing Unused Variable -
    package sonar.autofix;

public class MyServiceImpl {

private String name;// unused
private int id;// unused

}

Expected Output - Code Transformation Chain should result in "SUCCESS" and unused variables should get automatically removed.

Actual Output -
Unused variables are not removed.
Below Console output produced -

 INFO [main] - THE TRANSFORMATION CHAIN sonar:RemoveUselessVariables STARTS 
--------------------------------------------------------------------------------

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 INFO [main] - No sources changed

 INFO [main] - TRANSFORMATION CHAIN SUCCESS
--------------------------------------------------------------------------------

 INFO [main] - Total time: 4.653 seconds
 INFO [main] - Finished at: Wed, 5 Jul 2017 18:06:46
 INFO [main] - Final memory: 181 M/ 266 M
 INFO [main] - Total modified files: 0
--------------------------------------------------------------------------------

Analysis -
As it has Failed to load class "org.slf4j.impl.StaticLoggerBinder", so it is evident some jar is missing in the classpath.
Now, question is which jar it expects to be downloaded ? I can check the console in details to see if that jar is downloaded and if not then how to add that jar file in the ivy list to be included ?

Typo in Readme

The link to the chat has an issue. Not sure how to fix it.

screen shot 2017-04-18 at 08 02 36

Support multimodule projects

In maven multi-module projects, the system requires multiple walkmod.xml, one per each different classpath to analyze for some transformations.

Therefore, it is necessary a recursive execution from the root folder.

The suggested approach is to design an XML like this one, where module1 and module2 are relative subdirectories:

<walkmod>
    <modules>
        <module>module1</module>
        <module>module2</module>
    </modules>
</walkmod>

Walkmod: Getting through a proxy

Hi,

Having trouble getting through a proxy with Walkmod. I ran the following command.

walkmod apply - DconfigurationFile=ruleset.xml pmd

It runs through fine but at the very end when it tries to get some additional google java stuff. It fails with a timeout. I believe this is due to a proxy. I posted an image of the message.

image

I have tried configuring the proxy via environment variables WALKMOD_OPTS and also ANT_OPTS. I also configured the config/ivysetting.xml for the proxy as well. None of this worked. Please let me know if you need any additional information. Any help would be great!

Specifying custom formatting options

I wonder how can I use walkmod with two projects having different formatting settings.
From what I understood there is a file (walkmod/config/formatter.xml) controlling the formatter but that file is global, so if I change it and run walkmod for project A then I have to change it according to the settings of project B before run it on B. It would great to have an option to specify the formatter settings to use when launching walkmod. Maybe it is already possible and I missed it.

UseCollectionIsEmpty is not working as expected : changing the implementation logic

Example below class -

`package sonar.autofix;

import java.util.List;

public class CollectionIsEmpty {

public void check(List<String> myList){
	if(myList.size() > 0){
		System.out.println("My List is not Empty.");
	}
	if(myList.size() <= 0){
		System.out.println("My List is Empty.");
	}
	if(myList.size() == 0){
		System.out.println("My List is Empty.");
	}
}

}
`

Run -

walkmod apply sonar:UseCollectionIsEmpty

After modification first "if-block" is expected to be changed to "!list.isEmpty()" (not operator is missing)

`package sonar.autofix;

import java.util.List;

public class CollectionIsEmpty {

public void check(List<String> myList){
	if(myList.isEmpty()){
		System.out.println("My List is not Empty.");
	}
	if(myList.size() <= 0){
		System.out.println("My List is Empty.");
	}
	if(myList.isEmpty()){
		System.out.println("My List is Empty.");
	}
}

}

`

LocalVarsShouldComplyWithNamingConvention not working for Parameters

`package sonar.autofix;

public class LocalVarNaming {

public void create(String corporate_base){
	System.out.println("corporate_base = "+corporate_base);
}

}If I run -walkmod apply sonar:LocalVarsShouldComplyWithNamingConvention` causing compilation error.

`package sonar.autofix;

public class LocalVarNaming {

public void create(String corporateAsecorporate_base	public void create(String corporate_base){
	System.out.println("corporate_base = "+corporate_base);
}

}
`

Passing paramaters to ConfigurationProviders

I'm trying to implement a way to set the base directory for an execution and I have some doubts regarding to how pass the parameter.
Basically, the use case I want to fulfill is: "I want to execute some chain, and set as root for the execution some path that is not the current execution directory". I just need to pass a path, and prefix this to the walker, reader and writers paths found in the XML.

The thing is that I find that using a ConfigurationProvider to pass that information is not useful, because I need to pass the extra parameter to other ConfigurationProviders so that they can use that information to initialize instances (more precisely the XMLConfigurationProvider needs the base path).
As an alternative I can add the extra parameter to the paramaters Map in the Configuration instance and then copy them to the ChainAdapter in the ChainAdapterFactory, and finally, use them to modify the already initialized instances in the prepare method. Overall, this is a pain and this solution won't be valid if this "base directory" option is ever added to the XML as a tag/property.

For a simple common solution I think it would be usefull to review how ConfigurationManager works.
As far as I understand:

  • The simple constructors are not used.
  • The constructor being used (ConfigurationManager#L42) does not allow to customize a Configuration instance. Instead, it creates an empty instance that is then passed to all ConfigurationProviders.

I feel that the Configuration and the parameters Map instance is just what I need. What do you think about modifing the constructor to also recieve a Configuration?
I'm open to all suggestions.
As a side note, I have my doubts about all the initialization done in the ConfigurationProvider. Maybe it should be moved to another class that initialized Walkmod. That way we could avoid some duplicated code in the Facade...but maybe I'm overthinking ^^''

Extra space added when using the javalang:string-writer writer.

After running a dead-code-cleaner with no real changes, I see that some formatting has been altered unnecessarily, as in the case:
names.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList());
to
names.entrySet().stream().map( Map.Entry::getValue).collect(Collectors.toList());

Adding some extra space (8 spaces) before Map.Entry that should not be there.

Transformation chain fails with maven & checkstyle

Hi,

I'm trying to use walkmod for fixing checkstyle on the following maven project: https://github.com/INRIA/spoon . More specifically, as a test, I'm trying to fix checkstyle issue I had on this commit: INRIA/spoon@0d2d0af (it had wrong indent, and a problem with spaces somewhere in the file).

I installed last version on a macos, using homebrew:

193-51-236-54:Github urli$ walkmod -v
 INFO [main] - Java version: 1.8.0_111
 INFO [main] - Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
 INFO [main] - OS: Mac OS X, Vesion: 10.12.6
--------------------------------------------------------------------------------
                     _    _       _ _   ___  ___          _                     
                    | |  | |     | | |  |  \/  |         | |                    
                    | |  | | __ _| | | _| .  . | ___   __| |                    
                    | |/\| |/ _` | | |/ / |\/| |/ _ \ / _` |                    
                    \  /\  / (_| | |   <| |  | | (_) | (_| |                    
                     \/  \/ \__,_|_|_|\_\_|  |_/\___/ \__,_|                    
--------------------------------------------------------------------------------
An open source tool to apply code conventions
version 3.0 - February 2017 -
--------------------------------------------------------------------------------
Walkmod version "3.0"
Java version: 1.8.0_111
Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
OS: Mac OS X, Version: 10.12.6

So looking on the usage I first tried to call walkmod apply checkstyle on my specific commit, it ended up with the following stacktrace:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.407 s
[INFO] Finished at: 2017-08-11T14:06:21+02:00
[INFO] Final Memory: 51M/771M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:checkstyle (default) on project spoon-core: An error has occurred in Checkstyle report generation. Failed during checkstyle execution: There are 79 errors reported by Checkstyle 6.11.2 with checkstyle.xml ruleset. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
 INFO [main] - TRANSFORMATION CHAIN FAILS

--------------------------------------------------------------------------------
 INFO [main] - Total time: 21,256 seconds
 INFO [main] - Finished at: Fri, 11 Aug 2017 14:06:22
 INFO [main] - Final memory: 173 M/ 193 M
--------------------------------------------------------------------------------
 INFO [main] - Please, see the walkmod log file for details
ERROR [main] - TRANSFORMATION CHAIN (checkstyle) FAILS
An exeception has been produced during the null transformation - org.walkmod.util.location.LocationImpl@4215838f
	at org.walkmod.maven.providers.MavenProject.build(MavenProject.java:252)
	at org.walkmod.maven.providers.MavenProject.resolveClassLoader(MavenProject.java:368)
	at org.walkmod.maven.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:85)
	at org.walkmod.javalang.walkers.DefaultClasspathEvaluator.runClassLoaderInitializers(DefaultClasspathEvaluator.java:59)
	at org.walkmod.javalang.walkers.DefaultClasspathEvaluator.evaluate(DefaultClasspathEvaluator.java:21)
	at org.walkmod.javalang.walkers.DefaultJavaWalker.calculateClasspath(DefaultJavaWalker.java:147)
	at org.walkmod.javalang.walkers.DefaultJavaWalker.execute(DefaultJavaWalker.java:161)
	at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:41)
	at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38)
	at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:166)
	at org.walkmod.conf.entities.impl.ConfigurationImpl.executeChain(ConfigurationImpl.java:731)
	at org.walkmod.conf.entities.impl.ConfigurationImpl.execute(ConfigurationImpl.java:825)
	at org.walkmod.WalkModFacade.run(WalkModFacade.java:284)
	at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
	at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:42)
	at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
	at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
Caused by: org.walkmod.conf.ConfigurationException: Error executing: mvn clean install -DskipTests -DskipWalkmod in /Users/urli/Github/spoon
	... 17 more
Caused by: java.lang.Exception: Error executing: mvn clean install -DskipTests -DskipWalkmod in /Users/urli/Github/spoon
	... 17 more

Please note that in our project, a mvn install -DskipTests=true on this specific commit would fail because of the checkstyle errors in this commit.

Then I tried with the following walkmod.xml config file:

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd">
<walkmod>
    <conf-providers>
        <conf-provider type="maven"/>
    </conf-providers>
    <chain name="default">
        <transformation type="checkstyle"/>
    </chain>

</walkmod>

and then I obtained the following error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.740 s
[INFO] Finished at: 2017-08-11T14:12:03+02:00
[INFO] Final Memory: 51M/775M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:checkstyle (default) on project spoon-core: An error has occurred in Checkstyle report generation. Failed during checkstyle execution: There are 79 errors reported by Checkstyle 6.11.2 with checkstyle.xml ruleset. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
ERROR [main] - Invalid configuration
org.walkmod.conf.ConfigurationException: Error executing: mvn clean install -DskipTests -DskipWalkmod in /Users/urli/Github/spoon
	at org.walkmod.maven.providers.MavenProject.build(MavenProject.java:252)
	at org.walkmod.maven.providers.MavenProject.resolveClassLoader(MavenProject.java:368)
	at org.walkmod.maven.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:85)
	at org.walkmod.impl.DefaultConfigurationAdapter.prepare(DefaultConfigurationAdapter.java:56)
	at org.walkmod.conf.ConfigurationManager.addProviders(ConfigurationManager.java:64)
	at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:75)
	at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:79)
	at org.walkmod.WalkModFacade.readConfig(WalkModFacade.java:181)
	at org.walkmod.WalkModFacade.run(WalkModFacade.java:256)
	at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
	at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
	at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
	at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
Caused by: java.lang.Exception: Error executing: mvn clean install -DskipTests -DskipWalkmod in /Users/urli/Github/spoon
	... 13 more
ERROR [main] - Invalid configuration
java.lang.NullPointerException
	at org.walkmod.WalkModFacade.run(WalkModFacade.java:264)
	at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
	at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
	at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
	at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
Exception in thread "main" java.lang.NullPointerException
	at org.walkmod.WalkModFacade.run(WalkModFacade.java:284)
	at org.walkmod.WalkModFacade.apply(WalkModFacade.java:142)
	at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
	at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
	at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)

So any hint how to use walkmod in my case?

UseCollectionIsEmpty is not working as expected : changing the implementation logic : Cloned

It is not working for below logic -
if(0 < myList.size()){ System.out.println("My List is not Empty."); }
I personally feel, the code can be made simpler. I saw the code logic is too complex and that is why it is really difficult to maintain this code working in so many test-cases.

That is why I tried to make the code simpler - there are 2 main cases -

isEmpty
!isEmpty
Now, If we write the code such a way that a simple change would include / exclude (while fixing any bug) a particular condition from deriving any of the above. So, a Set data-structure would help us to hold the set of conditions. If anyone of them is working the entire set of conditions should be working.
walkmod/walkmod-sonar-plugin#12

Walkmod import-cleaner sample try is not working

I am new to use walkmod. I struggled to get started with it, it is not simple as it is written. I had to download codes, understand it but still no luck, I am still not able to run first demo "import-cleaner" to show case that sonar fixes can be automated. It is really frustrating.

I am listing down the concern --

  1. First of all it is not fully offline, it should be like if I want to use sonar-plugin, I should have proper help to download it only once like the way I do for walkmod-core and I'll set the path and I should be able to proceed.
  2. There is no way to set up proxy (if I m under corporate proxy), and it should not be so much confusing maven, ivy, http calls, there are so many things happening behind the scene, it is really night-mare to debug and understand the issue.
  3. The very first demo import-cleaner is not working in my machine. It gives below error -
    :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
    WARN [main] - download failed: org.apache.maven#maven-model-builder;3.2.5!maven-model-builder.jar
    ERROR [main] - D:\TCS\Workspace_Sonar_Automation\sonarfix.automation\walkmod.xml is invalid. Please, execute walkmod with -e to see the details.
    ERROR [main] - D:\TCS\Workspace_Sonar_Automation\sonarfix.automation\walkmod.xml is invalid. Please, execute walkmod with -e to see the details.
    Exception in thread "main" java.lang.NullPointerException
    at org.walkmod.WalkModFacade.run(WalkModFacade.java:284)
    at org.walkmod.WalkModFacade.check(WalkModFacade.java:303)
    at org.walkmod.commands.CheckCommand.execute(CheckCommand.java:40)
    at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
    at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
    D:\TCS\Workspace_Sonar_Automation\sonarfix.automation>

Get ScriptingQueryEngine - NoSuchBeanDefinitionException

While trying to test the example from http://walkmod.com/manual#script,
I get an exception. (See stacktrace at the end)
Walkmod version is 2.0.1

Please take a look at org.walkmod.conf.entities.impl.ConfigurationImpl.getBean(String, Map<?, ?>)
In ScriptProcessor the method invocation is context.getBean("org.walkmod.query.ScriptingQueryEngine", parameters);.

Now in "getBean" it might go into the first if-block (I have troubles getting my dev environment to work and can't step in with the debugger)

    if (beanFactory != null && beanFactory.containsBean(name)) {
        result = beanFactory.getBean(name);
    }

But the next if-block is not an 'else' statement, it is:

    if (!name.contains(":")) {
        result = beanFactory.getBean("org.walkmod:walkmod-" + name + "-plugin:" + name);
    }

So it could overwrite result. Also, as seen in the stacktrace, the String with "-plugin" etc is being constructed, while the class to be loaded is simply a local class and the simpler "org.walkmod.query.ScriptingQueryEngine" should suffice. Or am I missing something?

ERROR [main] - TRANSFORMATION CHAIN (example-chain) FAILS
An exeception has been produced during the null transformation - org.walkmod.util.location.LocationImpl@4de41af9
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:250)
        at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:265)
        at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:41)
        at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38)
        at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:165)
        at org.walkmod.WalkModFacade.executeAllChains(WalkModFacade.java:904)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:375)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:164)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:189)
Caused by: java.lang.reflect.InvocationTargetException
        ... 14 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.walkmod.walkers.AbstractWalker.visit(AbstractWalker.java:112)
        at org.walkmod.walkers.AbstractWalker.visit(AbstractWalker.java:161)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:332)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:127)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.accept(DefaultJavaWalker.java:74)
        ... 14 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.walkmod:walkmod-org.walkmod.query.ScriptingQueryEngine-plugin:org.walkmod.query.ScriptingQueryEngine' is defined
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
        at org.walkmod.conf.entities.impl.ConfigurationImpl.getBean(ConfigurationImpl.java:137)
        at org.walkmod.walkers.VisitorContext.getBean(VisitorContext.java:119)
        at org.walkmod.scripting.ScriptProcessor.initialize(ScriptProcessor.java:74)
        at org.walkmod.scripting.ScriptProcessor.visit(ScriptProcessor.java:91)
        ... 23 more

org.xml.sax.SAXParseExceptionpublicId: -//WALKMOD//DTD; systemId: http://<ClientSite>/ProxyWarning.html; lineNumber: 1; columnNumber: 3; The markup declarations contained or pointed to by the document type declaration must be well-formed.

Hi,
I am facing the below error while integrating walkmod to my spring MVC application. I feel it might because of proxy since i am in VPN. all the proxy configuration is already configured in my settings.xml. Do I need to configure proxy somewhere else for walkmod or is a different issue?

INFO [main] - C:\Users<User>\IdeaProjects<project-folder>\walkmod.xml [ok]
FATAL [main] - The markup declarations contained or pointed to by the document type declaration must be well-formed. at (-//WALKMOD//DTD:1:3)
org.xml.sax.SAXParseExceptionpublicId: -//WALKMOD//DTD; systemId: http:///ProxyWarning.html; lineNumber: 1; columnNumber: 3; The markup declarations contained or pointed to by the document type declaration must be well-formed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2039)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:306)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1174)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1045)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:959)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
at org.walkmod.util.DomHelper.parse(DomHelper.java:90)
at org.walkmod.conf.providers.PluginsConfigurationProvider.lookUpDocument(PluginsConfigurationProvider.java:114)
at org.walkmod.conf.providers.PluginsConfigurationProvider.init(PluginsConfigurationProvider.java:80)
at org.walkmod.conf.ConfigurationManager.executeConfigurationProviders(ConfigurationManager.java:123)
at org.walkmod.conf.ConfigurationManager.addProviders(ConfigurationManager.java:61)
at org.walkmod.conf.ConfigurationManager.(ConfigurationManager.java:75)
at org.walkmod.conf.ConfigurationManager.(ConfigurationManager.java:79)
at org.walkmod.WalkModFacade.readConfig(WalkModFacade.java:181)
at org.walkmod.WalkModFacade.run(WalkModFacade.java:256)
at org.walkmod.WalkModFacade.check(WalkModFacade.java:303)
at org.walkmod.commands.CheckCommand.execute(CheckCommand.java:40)
at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)
ERROR [main] - C:\Users<user>\IdeaProjects<Project>\walkmod.xml is invalid. Please, execute walkmod with -e to see the details.
ERROR [main] - C:\Users<user>\IdeaProjects<Project>\walkmod.xml is invalid. Please, execute walkmod with -e to see the details.
Exception in thread "main" java.lang.NullPointerException
at org.walkmod.WalkModFacade.run(WalkModFacade.java:284)
at org.walkmod.WalkModFacade.check(WalkModFacade.java:303)
at org.walkmod.commands.CheckCommand.execute(CheckCommand.java:40)
at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:172)
at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:197)

image

Need better command line parameter handling

Dear @rpau,

the --verbose parameter has 2 consequences currently which I need separately in different
combinations:

  1. More verbose output especially on errors
  2. continue-on-error mode

I suggest moving the second function to a new parameter.
If you don't want to change current behavior I suggest --stop-on-error.
The levels of ouput would be:

Verbose - print stack traces of various exceptions
Normal - just print mostly one liners of exceptions above
Silent/quiet - Do not print in case of errors

I can provide a pull request when we agree on the semantics.

Cal

unable to run walkmod on springboot applications

Unable to run walkmod on spring boot applications,

i have added following plugin in my pom.xml

            <plugin>
                <groupId>org.walkmod</groupId>
                <artifactId>maven-walkmod-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>apply</goal>
                        </goals>
                        <configuration>
                            <skipWalkmod>${skipWalkmod}</skipWalkmod>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

when trying commad walkmod check

getting following error

ERROR [main] - TRANSFORMATION CHAIN (default) FAILS
An exeception has been produced during the null transformation - org.walkmod.uti
l.location.LocationImpl@4b1a43d8
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:261)
        at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:276)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.execute(DefaultJavaWal
ker.java:160)
        at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalk
erInvocation.java:41)
        at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation
.java:38)
        at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java
:165)
        at org.walkmod.WalkModFacade.executeAllChains(WalkModFacade.java:911)
        at org.walkmod.WalkModFacade.check(WalkModFacade.java:477)
        at org.walkmod.commands.CheckCommand.execute(CheckCommand.java:40)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)
Caused by: java.lang.reflect.InvocationTargetException
        ... 15 more
Caused by: Error processing the analysis of [D:\tmp_other\testJhip3\bugtest\src\
main\java\com\kkorada\mdtest\BugtestApp.java] - org.walkmod.util.location.Loca
tionImpl@6d469831
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.addType(TypesL
oaderVisitor.java:465)
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.loadClassesFro
mJar(TypesLoaderVisitor.java:530)
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.loadClassesFro
mPackage(TypesLoaderVisitor.java:555)
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.visit(TypesLoa
derVisitor.java:391)
        at org.walkmod.javalang.ast.ImportDeclaration.accept(ImportDeclaration.j
ava:109)
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.visit(TypesLoa
derVisitor.java:643)
        at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(Symb
olVisitorAdapter.java:159)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalke
r.java:198)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.accept(DefaultJavaWalk
er.java:86)
        ... 15 more
Caused by: java.lang.RuntimeException: Ops!. Error loading org.springframework.b
oot.actuate.autoconfigure.CrshAutoConfiguration$CrshBootstrapBean. Some missing
runtime dependencies?
        ... 24 more
Caused by: java.lang.NoClassDefFoundError: org/crsh/plugin/PluginLifeCycle
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.walkmod.maven.providers.MavenProject$1.loadClass(MavenProject.jav
a:429)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.walkmod.javalang.compiler.types.TypesLoaderVisitor.addType(TypesL
oaderVisitor.java:420)
        ... 23 more
Caused by: java.lang.ClassNotFoundException: org.crsh.plugin.PluginLifeCycle
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.walkmod.maven.providers.MavenProject$1.loadClass(MavenProject.jav
a:429)
        at org.walkmod.maven.providers.MavenProject$1.loadClass(MavenProject.jav
a:434)
        ... 39 more

and corresponding Bugtest.java file is

package com.kkorada.mdtest;

import com.kkorada.mdtest.config.Constants;
import com.kkorada.mdtest.config.JHipsterProperties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.*;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.core.env.SimpleCommandLinePropertySource;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collection;

@ComponentScan
@EnableAutoConfiguration(exclude = { MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class })
@EnableConfigurationProperties({ JHipsterProperties.class, LiquibaseProperties.class })
public class BugtestApp {

    private static final Logger log = LoggerFactory.getLogger(BugtestApp.class);

    @Inject
    private Environment env;

    /**
     * Initializes bugtest.
     * <p>
     * Spring profiles can be configured with a program arguments --spring.profiles.active=your-active-profile
     * <p>
     * You can find more information on how profiles work with JHipster on <a href="http://jhipster.github.io/profiles/">http://jhipster.github.io/profiles/</a>.
     */
    @PostConstruct
    public void initApplication() {
        if (env.getActiveProfiles().length == 0) {
            log.warn("No Spring profile configured, running with default configuration");
        } else {
            log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
            Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
            if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_PRODUCTION)) {
                log.error("You have misconfigured your application! " +
                    "It should not run with both the 'dev' and 'prod' profiles at the same time.");
            }
            if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_CLOUD)) {
                log.error("You have misconfigured your application! " +
                    "It should not run with both the 'dev' and 'cloud' profiles at the same time.");
            }
        }
    }

    /**
     * Main method, used to run the application.
     *
     * @param args the command line arguments
     * @throws UnknownHostException if the local host name could not be resolved into an address
     */
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication app = new SpringApplication(BugtestApp.class);
        SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
        addDefaultProfile(app, source);
        Environment env = app.run(args).getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\thttp://127.0.0.1:{}\n\t" +
                "External: \thttp://{}:{}\n----------------------------------------------------------",
            env.getProperty("spring.application.name"),
            env.getProperty("server.port"),
            InetAddress.getLocalHost().getHostAddress(),
            env.getProperty("server.port"));

    }

    /**
     * If no profile has been configured, set by default the "dev" profile.
     */
    private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
        if (!source.containsProperty("spring.profiles.active") &&
                !System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {

            app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
        }
    }
}

RemoveUnusedMethodParameters is not working for interface designs

ksksk
`package sonar.autofix;

public class UseLessParameter {

}

interface IService{
void serve(String userId);
}

class ServiceImpl implements IService{
public void serve(String userId) {
System.out.println("userId = "+userId);
}
}
`

Now, If we run -
walkmod apply sonar:RemoveUnusedMethodParameters

It often removes the last parameter / all parameters from the interface, keeping implementations unchanged. Sometimes, it removes parameters from the invocation keeping interfaces/implementations unchanged. As a result, it always produces compilation errors.

After running the command - it shows 0 mdified files but actually, modified the above file as below -

`package sonar.autofix;

public class UseLessParameter {

}

interface IService{
void serve();
}

class ServiceImpl implements IService{
public void serve(String userId) {
System.out.println("userId = "+userId);
}
}
`

Working Directories

It would be helpful if, instead of having to copy the content of the walkmod.xml file from the web, walkmod was able to set a given directory as a walkmod working directory.

Say for instance:

$> walkmod --setWorkingDirectoy="$PATH"

and that would create automatically the walkmod.xml file in $PATH, and any other infrastructure that is (or may be in a future) required. That would make walkmod more self-contained.

(btw, nice work!)

Code conventions to improve PRs

Should we define some coding conventions?
It's a thing I don't like because I think it supresses part of the developers creativity, but I use Intellj defaults which differs from eclipse defaults and GitHub has some issues compating PR's files.
For instance I use spaces and you use tabs, I don't follow the 80 chars rule...also seems to be a problem with linebreaks, even when I use windows8, I guess intellj is using unix format.

As a side note, I use eclipse at work and intellj for personal stuff, so I could switch. But I preffer the second because gralde/groovy works (gradle in eclipse is in baby-steps right now), better maven integration, better GitHub integration, and finally because most people uses it in OS so I decided to move after wasting time changing the formatting of eclipse to be the same.

You're the lead so you define how to proceed. I will only ask for one thing, could we change the 80 char limit to 120.

Introduce the walkmod.xml syntax in the onboard screen

Hi!

I just logged in to walkmodhub. I just activated it for one of my OS projects, and I've seen that there are four steps to finally get a PR with proposed changes.

The steps are obvious (congratulations for that, clarifying that kind of processes are not an easy task), but they will be better if I can go to a place where the walkmod.xml is explained. I'm sure that I will find it, but I think it's something to improve in the onboarding process

image

Don't hesitate to close this issue if you think that it is not important :·)

And thanks for the work, again! :·)

Typo in the quickstart website

Trying to find how to start with the project, I found the example walkmod.xml. But it smells that the [2.0, 3.0) is not as good as it could be. Starting with [ and ending with ) ?

http://walkmod.com/manual#quick_start

image

BTW I don't know if this project is the good one... but I didn't found any better than this :·)

Thanks for your work!

Allow having walkmod.xml outside of sources

Not a big deal but I would like to keep one walkmod.xml for several projects and be able to specify path to it using WALKMOD_OPTS. I would submit a pull request but don't really understand all those getting/setting of user.dir, also new File(System.getProperty("user.dir")) found on several places - this I believe is equal to new File("")

`writer path` not working correctly when using groovy scripts

Hi,

I've seen that the writer's path option is not working as espected when using a groovy script to modify sources.
The thing is that resources are always modified in the source folder, and only copied when the source file is not modified...it's pretty weird.
I've created a test project to ilustrate this https://github.com/abelsromero/walkmod-output-issue.
When you execute the App class for the first time the result is:

  • The path org.walkmod.gradle.example is created in the writer path --> OK
  • The source files HelloWorld,PersonPojo are modified in the source path --> KO
  • The source file Person is copied to the writer path+package location. This is file not modified. --> OK

When you execute the App class a second time (no matter if you delete the output path) the result is:

  • The path org.walkmod.gradle.example is created in the writer path --> OK
  • The source files HelloWorld,PersonPojo are not modified, because they were already chaged the first time and get copied to the output path --> OK
  • The source file Person is copied to the writer path+package location. --> OK

Am I doing something wrong? From the quickstart (http://walkmod.com/manual.html#quick_start) I guess not :%

Unknown options are ignored by the walkmod tool

I tried passing several options life -X or -Abc and walkmod seems to accept them without complaining. I was expecting an error to be reported.

I did that because I was trying to enable more verbosity using -X like I do with maven.

create a walkmod-modifiers-plugin

Create a walkmod plugin to restrict as much as possible the modifiers of a field, method or variable.
e.g: mark as "final" those read only variables.

[enhancement] Create a single unified method for WalkmodFacade

From @abelsromero on August 29, 2015 9:36

As a developer/integrator I'd like to be able to launch walkmod chains through a single method, no matter what configuration I am passing or how the chains are defined.

I've seen that right now the facade offers many methods whose only difference is the number of parameters (error handling, vebose, etc.). Also some require to set the configuration as a file, and some as a path.

This approach is correct with the current set of settings, but hinders the possibility to pass more features that may appear in the future.
What I am proposing is creating a single method with the following specification:

  • A Map<String, Object> object: each parameter can be set with a predefined key: "verbose", "offline", etc. This allows to pass even real object, that could be injected in the context. To ease the configuration, some helper class can be created (here is an example OptionsBuilder). Optionally, an overloaded method with the helper method could be offered. As an example of future option I'd like to be able to set the base directory for the walkers/visitors, so I can have a folder with the walkmod file in a parent project and the apply the changes to child projects without having to copy it to each one.
  • ConfigurationProvider instance: right now is it possible to use other providers instead of Ivy, however, the Facade does not allow it. Btw, nothing against ivy, but in corporate enviroments (with proxy and shitty network) Ivy's bootstrap can take quite a long time, whereas being able to pass a direct classloader alreay initialize (e.g. by maven or gradle) can remove that time and simplify the integration with other tools.
  • File or String walkmod file: I preffer a File, but the main point is defining a single point of entry. I don't have a strong opinion on either options as long as one single option is set. Also I'm thinking that the "walkmod file" could be passed with some interface or wrapper. In the future it would be cool to be able to pass a configuration in some other way, like an object created with a DSL. Anyway, that can be done in the future. wdyt? Should walkmod define it or stick with the file/path? imho, It's a shame ConfigurationProvider name is already taken ><

Current methods can be marked as @deprecated.

Overall, this proposal avoid changes in the integrators interface regarding the evolution of the API, and makes the Facede more firendly not only to Java but to other languages like Groovy.

wdyt?

Copied from original issue: walkmod/walkmod-cmd#2

Error executing examples from site

Hi,

I'm trying the tool after some time and I find that some old examples seem to fail with the last version, or else, I'm missing something, that could be.

I downloaded version 1.3.0 from https://bitbucket.org/rpau/walkmod/downloads and I'm attempting execute the script example (http://walkmod.com/manual.html#script) but I get the following error:

 INFO [main] - Java version: 1.7.0
 INFO [main] - Java Home: C:\home\bin\jdk1.7.0_x64\jre
 INFO [main] - OS: Windows 7, Vesion: 6.1
--------------------------------------------------------------------------------
                     _    _       _ _   ___  ___          _
                    | |  | |     | | |  |  \/  |         | |
                    | |  | | __ _| | | _| .  . | ___   __| |
                    | |/\| |/ _` | | |/ / |\/| |/ _ \ / _` |
                    \  /\  / (_| | |   <| |  | | (_) | (_| |
                     \/  \/ \__,_|_|_|\_\_|  |_/\___/ \__,_|
--------------------------------------------------------------------------------
An open source tool to apply code conventions
version 1.2 - July 2015 -
--------------------------------------------------------------------------------
 INFO [main] - c:\home\data\github\gradle-walkmod-plugin\src\test\resources\walkmod.xml [ok]
:: loading settings :: url = file:/C:/home/bin/walkmod-1.3.0/config/ivysettings.xml
:: loading settings :: url = jar:file:/C:/home/bin/walkmod-1.3.0/lib/ivy-2.4.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: org.walkmod#walkmod-imports-cleaner-plugin-caller;working
        confs: [default]
        found org.walkmod#walkmod-imports-cleaner-plugin;2.0 in maven2
        found org.walkmod#javalang;3.2.0 in maven2
        [3.2.0] org.walkmod#javalang;[3.0.0, 4.0.0)
        found org.walkmod#merger;1.0.1 in maven2
        [1.0.1] org.walkmod#merger;[1.0.1, 2.0)
        found org.walkmod#walkmod-javalang-plugin;2.3.2 in maven2
        [2.3.2] org.walkmod#walkmod-javalang-plugin;[2.0, 3.0)
        found org.walkmod#javalang;4.2.2 in maven2
        [4.2.2] org.walkmod#javalang;[3.1.0, 5.0.0)
        found org.walkmod#javalang-compiler;2.1.0 in maven2
        [2.1.0] org.walkmod#javalang-compiler;[2.0.0, 3.0.0)
        found log4j#log4j;1.2.16 in maven2
        found org.walkmod#walkmod-java-formatter-plugin;2.2.0 in maven2
        [2.2.0] org.walkmod#walkmod-java-formatter-plugin;[2.0, 3.0)
        found org.walkmod#javalang;4.2.2 in maven2
        [4.2.2] org.walkmod#javalang;[4.1.0, 5.0.0)
        found org.eclipse.core#org.eclipse.core.contenttype;3.4.100 in maven2
        found org.eclipse.equinox#org.eclipse.equinox.preferences;3.4.1 in maven2
        found org.eclipse.equinox#org.eclipse.equinox.common;3.6.0 in maven2
        found org.eclipse.equinox#org.eclipse.equinox.registry;3.5.101 in maven2
        found org.eclipse.core#org.eclipse.core.expressions;3.4.300 in maven2
        found org.eclipse.core#org.eclipse.core.runtime;3.7.0 in maven2
        found org.eclipse.osgi#org.eclipse.osgi;3.7.1 in maven2
        found org.eclipse.core#org.eclipse.core.jobs;3.5.100 in maven2
        found org.eclipse.equinox#org.eclipse.equinox.app;1.3.100 in maven2
        found org.eclipse.core#org.eclipse.core.filesystem;1.3.100 in maven2
        found org.eclipse.core#org.eclipse.core.resources;3.7.100 in maven2
        found org.eclipse.jdt#org.eclipse.jdt.core;3.10.0 in maven2
        found org.eclipse.text#org.eclipse.text;3.5.101 in maven2
:: resolution report :: resolve 14353ms :: artifacts dl 56ms
        :: evicted modules:
        org.walkmod#javalang;3.2.0 by [org.walkmod#javalang;4.2.2] in [default]
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      default     |   21  |   6   |   0   |   1   ||   26  |   0   |
        ---------------------------------------------------------------------
 INFO [main] - ** THE TRANSFORMATION CHAIN clean STARTS **
--------------------------------------------------------------------------------
 INFO [main] - >> cosa.Person
 INFO [main] - TRANSFORMATION CHAIN FAILS

--------------------------------------------------------------------------------
 INFO [main] - Total time: 0,058 seconds
 INFO [main] - Finished at: Tue, 25 Aug 2015 11:07:12
 INFO [main] - Final memory: 207 M/ 244 M
--------------------------------------------------------------------------------
 INFO [main] - Please, see the walkmod log file for details
ERROR [main] - TRANSFORMATION CHAIN (clean) FAILS
An exeception has been produced during the walkmod:commons:import-cleaner transformation - org.walkmod.util.location.LocationImpl@48ab464e
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:260)
        at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:275)
        at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:42)
        at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38)
        at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:165)
        at org.walkmod.WalkModFacade.executeChainAdapter(WalkModFacade.java:642)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:269)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:181)
Caused by: java.lang.reflect.InvocationTargetException
        ... 12 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.walkmod.walkers.AbstractWalker.write(AbstractWalker.java:200)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.write(DefaultJavaWalker.java:257)
        at org.walkmod.walkers.AbstractWalker.writeAll(AbstractWalker.java:179)
        at org.walkmod.walkers.AbstractWalker.visit(AbstractWalker.java:171)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:329)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:127)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.accept(DefaultJavaWalker.java:74)
        ... 12 more
Caused by: java.lang.NullPointerException
        at org.walkmod.javalang.actions.ActionsApplier.setText(ActionsApplier.java:42)
        at org.walkmod.javaformatter.writers.EclipseWriter.getContent(EclipseWriter.java:229)
        at org.walkmod.writers.AbstractFileWriter.write(AbstractFileWriter.java:118)
        ... 23 more

I've tried several scripts and gthe cleaner plugin and the error is always the same. An empty file is created in the output folder, but nothins is written in.

create a walkmod-visitor-plugin

Create a plugin that for a set of classes that are subclasses (or not) from an specific class, creates a visit method in the visitor class and the accept method in this class.

Applying a local plugin

To deploy a walkmod plugin, docs suggest:

[...] run mvn install and follow these instructions to upload a maven artifact into the official maven repository

I've never done this before and instructions are not simple at all.
Is there anyway of quickly try my plugins in my projects without having to deploy them?

If not, can you provide instructions of how to deploy a plugin?

Running walkmod in the whole Android project

When I run walkmod with a basic Android project, it creates 2 walkmod.xml files:

./walkmod.xml
./app/walkmod.xml

If I apply walkmod in the root, it will not apply to the whole project. How can I apply walkmod with a single configuration to whole project?

Maven sub projects not handled

Hi,
I'm testing walkmod on a maven project. I want to apply a refactoring action. Therefore I'm following the documentation of walkmod-refactor-plugin and execute the following sequence of command:

walkmod add -DrefactoringConfigFile="src/main/walkmod/refactor/refactoring-methods.json" refactor:classes
walkmod apply

After the execution of the first command I get a bunch of walkmod.xml file created under each sub project.
What I notice is that only the root walkmod.xml contains the transform element. The others are just empty:

Root file

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd">
<walkmod>
    <modules>
        <module>parent</module>
        <module>lib</module>
        <module>feature</module>
        <module>itest</module>
    </modules>
    <transformation type="refactor:classes">
        <param name="refactoringConfigFile">src/main/walkmod/refactor/refactoring-methods.json</param>
    </transformation>
</walkmod>

sub projects file

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD"  "http://www.walkmod.com/dtd/walkmod-1.1.dtd" >
<walkmod>
</walkmod>

When I run the apply command from the root project and nothing is transformed.
In order to get the transformation applied I must run the first command add in all the sub projects and then run the apply command from the root one.
It sounds like there is no transitivity of the root configuration.
Is this a bug or should I proceed differently?

Thanks in advance,
Romain

is walkmod down?

we see walkmod site is down since yesterday.. is there anything can be done..

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.