-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.html
More file actions
385 lines (337 loc) · 18.3 KB
/
docs.html
File metadata and controls
385 lines (337 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WalkMod User Guide</title>
<meta name="description" content="Guide to automatically fix coding style issues using WalkMod" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Loading Bootstrap -->
<link href="css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Loading Flat UI -->
<link href="css/flat-ui.min.css" rel="stylesheet">
<link href="docs/assets/css/demo.css" rel="stylesheet">
<link rel="stylesheet" href="codemirror/lib/codemirror.css">
<link rel="stylesheet" href="codemirror/theme/zenburn.css">
<link rel="stylesheet"
href="codemirror/addon/hint/show-hint.css">
<link rel="shortcut icon" href="favicon.ico">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
<script src="/public/js/vendor/html5shiv.js"></script>
<script src="/public/js/vendor/respond.min.js"></script>
<![endif]-->
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js',
'ga');
ga('create', 'UA-43600294-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- Static navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
</button>
<a class="navbar-brand" href="/" style="font-family: ubuntu-titletitle; font-size: 30px;">WalkMod</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="https://blog.walkmod.com">Blog</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="page-header" id="banner">
<div class="row">
<h1>WalkMod user guide</h1>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#installation">
Installation
</button>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#quickfixes">
Apply quick fixes
</button>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#integration">
Integration
</button>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#usage">
Basic Usage
</button>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#formatters">
Use formatters
</button>
<button type="button" class="btn btn-primary btn-lg btn-block"
data-href="#search_plugins">
Looking for plugins
</button>
</div>
</div>
<div class="col-md-9">
<section id="installation" class="bs-docs-section">
<h2>Installation</h2>
<p>
Walkmod is a Java tool, so you must have <a rel="nofollow"
href="http://www.oracle.com/technetwork/java/" target="_blank">Java</a>
(≥ 1.7) installed in order to proceed.
</p>
<ol>
<li>Download and unzip the <a
onclick="ga('send', 'event', 'outbound', 'download', '3.0.0', {
'transport': 'beacon',
'hitCallback': function(){
document.location = 'https://bitbucket.org/rpau/walkmod/downloads/walkmod-3.0.0-installer.zip';
}
}); return false;"
rel="nofollow"
href="https://bitbucket.org/rpau/walkmod/downloads/walkmod-3.0.0-installer.zip"
type="application/x-zip-compressed">distribution archive</a> to
the directory you wish to install walkmod.
</li>
<li>Add the <code>WALKMOD_HOME</code> environment variable,
whose value must be the instalation directory.
</li>
<li>Add <code>WALKMOD_HOME/bin</code> environment variable to
your <code>PATH</code>.
</li>
<li>Open a prompt and type<code> walkmod --version</code>. It
should print out your installed version of walkmod, for example:
<pre class="prettyprint prettycode" style="margin-top:5px;">Walkmod version "3.0"
Java version: 1.8.0_101
Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
OS: Mac OS X, Version: 10.12.2</pre>
</li>
</ol>
</section>
<section id="quickfixes" class="bs-docs-section">
<h2>Apply quick fixes</h2>
<p>WalkMod started as a framework to write code transformations. However, most of the users look for quick fixes
for existing static code analysis tools. Here appear the commands to get the results.</p>
<div>
<h4>For PMD</h4>
<pre>walkmod apply -DconfigurationFile=rulesets/java/basic.xml pmd</pre>
</div>
<div>
<h4>For CheckStyle</h4>
<pre>walkmod apply checkstyle</pre>
</div>
<div>
<h4>For SonarQube</h4>
<pre>walkmod apply -DauthToken="THIS_IS_MY_TOKEN" -DsonarHost="https://sonarqube.com" sonar</pre>
</div>
<p>If you are you interested to selectively apply the required changes <b>incrementally</b>, you need to use <a href="/hub">WalkModHub</a>.
Otherwise, if you want to learn how to use more complex code transformations through a fixed configuration (<code>walkmod.xml</code>), read the <a href="#usage">Basic Usage</a>.
</p>
</section>
<section id="integration" class="bs-docs-section">
<h2>Integration</h2>
<div>
<h3>Maven</h3>
You can run WalkMod in your
build process (PMD, CheckStyle or SonarQube) by adding the following <a href="https://walkmod.github.io/maven-walkmod-plugin">Maven WalkMod plugin</a> in
your <code>pom.xml</code>. This example, shows you how to apply quick fixes for PMD using Maven.
<pre>
<plugin>
<groupId>org.walkmod.maven.plugins</groupId>
<artifactId>walkmod-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<configuration>
<chains>pmd</chains>
<properties>rulesets/java/basic.xml</properties>
</configuration>
</execution>
</executions>
</plugin>
</pre>
And run
<pre>
mvn package
</pre>
</div>
<div>
<h3>Gradle</h3>
You can also run WalkMod in your gradle project by adding the following <a href="https://github.com/walkmod/gradle-walkmod-plugin">Gradle WalkMod plugin</a> in
your <code>build.gradle</code>. This example, shows you how to apply quick fixes for PMD using Gradle.
<pre>buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.walkmod:gradle-walkmod-plugin:0.0.1'
}
}
apply plugin: 'walkmod'
walkmod {
chains = [ 'pmd' ]
}
</pre>
And run
<pre>
gradle walkmodApply
</pre>
</pre>
</div>
</section>
<section id="usage" class="bs-docs-section">
<h2>Basic Usage</h2>
<p>Let's see how to use walkmod with a simple Java project. With this aim, we have prepared this tutorial, which executes walkmod to clean
unused imports in a simple <a href="https://maven.apache.org/" target="_blank">maven</a> project. Please, before continuing with this tutorial, verify that
you have installed <a href="https://maven.apache.org/" target="_blank">maven</a> and <a href="https://git-scm.com/" target="_blank"> git</a>.</p>
<p>
Now, follow the next instructions.
</p>
<ol>
<li><b>Open your prompt.</b></li>
<li>
<b>Run</b> <code>git clone https://github.com/walkmod/quickstart.git</code>
<p>It downloads the source code of our example.</p>
</li>
<li>
<b>Run</b> <code>cd quickstart</code>
<p> It enters to the root project folder. This project, as many maven projects, contains the sources in the <code>src/main/java</code> directory.
Please, check that the file <code>src/main/java/org/walkmod/quickstart/model/Tweet.java</code> contains an unused import for <code>java.util.Calendar</code>.
</p>
</li>
<li>
<b>Run</b> <code>walkmod add imports-cleaner</code>
<p>It creates, if it is missing, a <code>walkmod.xml</code> file and adds the imports-cleaner plugin in the configuration.
</p>
</li>
<li>
<b>Run</b> <code>walkmod apply</code>
<p>It executes walkmod in the project and voila! it has removed an unused import in the class <code>org.walkmod.quickstart.model.Tweet</code>.
</p>
<pre style="font-size:10px;">
INFO [main] - ** STARTING TRANSFORMATIONS CHAINS **
-----------------------------------------------------------
INFO [main] - >>org.walkmod.quickstart.model.Tweet
------------------------------------------------------------
INFO [main] - TRANSFORMATION CHAIN SUCCESS
------------------------------------------------------------
INFO [main] - Total time : 0,96 seconds
INFO [main] - Finished at : Mon, 28 Dec 2015 10:04:06
INFO [main] - Final memory : 65 M/ 88 M
INFO [main] - Total modified files : 1
</pre>
</li>
<li><b>Run</b> <code>git diff</code> to check the differences. </li>
<li><b>Run</b> <code>mvn package</code> to check if it compiles. </li>
</ol>
<p>
</section>
<section id="formatters" class="bs-docs-section">
<h2>Use Formatters</h2>
<p>
Code formatters specify the appearance of the code: indentation, when to use or avoid parenthesis or brackets,
etc, but never about the contents of the code.
</p>
<p>
For many organizations, having code conventions about the code format is really important, because otherwise,
people usually reformat the code created by other people continuously, and thus, becomes impossible understand
the changes history.
</p>
<p>
One of the most well-known formatter tools is the Eclipse formatter. If you want to use this,
run the following command:
</p>
<pre class="prettyprint prettycode">walkmod set-writer -DconfigFile="myformatter.xml" java-formatter</pre>
</section>
<section id="search_plugins" class="bs-docs-section">
<h2>Looking for plugins</h5>
<p>With Walkmod you apply quick fixes by means of code transformations. In fact, the list of plugins
allows you publishing and applying quick fixes for your favorite static code analysis tool (e.g PMD, SonarQube, CheckStule)
in any project. In order to discover which plugin you need, follow the next instructions:
<ol><li>Run <code>walkmod plugins</code> to print the list of available Walkmod plugins.</p></li>
<pre style="font-size:10px;">...
│ │ │ │
├───────────────────┼─────┼──────────────────────────────────────────────────┤
│ checkstyle │ │ Walkmod plugin to automatically fix the reported │
│ │ │ problems by Checkstyle. │
│ │ │ │
│ │ │ URL:https://github.com/walkmod/walkmod-checkstyl │
│ │ │ e-plugin │
├───────────────────┼─────┼──────────────────────────────────────────────────┤
│ pmd │ │ Walkmod plugin to automatically fix the reported │
│ │ │ problems by PMD. │
│ │ │ │
│ │ │ URL:https://github.com/walkmod/walkmod-pmd-plugi │
│ │ │ n │
├───────────────────┼─────┼──────────────────────────────────────────────────┤
...
</pre>
<li>Run <code>walkmod inspect $plugin-id</code> to discover the transformations of an specific plugin. For example:
<pre class="prettyprint prettycode">walkmod inspect pmd</pre>
And the contents are as follows:
<pre style="font-size:10px;">┌─────────────────────────────────────────────┬────────────────┬──────────────────────────────┬─────────────┐
│ TYPE NAME (ID) │ CATEGORY │ PROPERTIES │ DESCRIPTION │
├─────────────────────────────────────────────┼────────────────┼──────────────────────────────┼─────────────┤
│ pmd │ transformation │ configurationFile:String │ unavailable │
└─────────────────────────────────────────────┴────────────────┴──────────────────────────────┴─────────────┘
</pre>
These identifiers (ID) are the parameters used in the <code>walkmod add $ID</code> command. Properties, such as <code>configurationFile</code>,
needs to be passed as a dynamic argument.
<pre class="prettyprint prettycode">walkmod add -DonfigurationFile=XXXXX pmd</pre>
</li>
<div class="bs-callout bs-callout-warning">
<li>
Many plugins, specially those that apply refactorings (e.g PMD, SonarQube, refactoring..), require to resolve your classpath to determine the type of every single expression of your code and, in the case
of method calls, which is the associated method signature. Walkmod resolves your project's classpath if it is built using Maven or Gradle. However, if it is an <b>Apache Ant</b> project, you should
execute the following instruction after building your project (assuming that your classpath is <code>"bin;lib/guava.jar;lib/log4j.jar"</code>):
<pre class="prettyprint prettycode">walkmod add -Dclasspath="bin;lib/guava.jar;lib/log4j.jar" rawclasspath</pre>
</li>
</div>
</ol>
</section>
</div>
</div>
</div>
<footer style="text-align: center; padding-top: 20px;margin-top:50px;"
class="walkmodhub-footer">
<a href="https://groups.google.com/d/forum/walkmod" rel="nofollow"
target="_blank">Google Groups</a>  <a
href="https://twitter.com/walkmod" target="_blank">Twitter</a>
<a href="http://github.com/rpau/walkmod-core" rel="nofollow"
target="_blank">GitHub</a><br /> Designed and built by <a
href="https://twitter.com/raquelpau" rel="nofollow" target="_blank">@raquelpau</a>
(2016).<br /> Code licensed under <a
href="http://www.gnu.org/licenses/lgpl.html" rel="nofollow"
target="_blank">GNU Lesser General Public License</a>.
</footer>
</body>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/vendor/video.js"></script>
<script src="js/flat-ui.min.js"></script>
<script src="js/docs.js"></script>
</html>