Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / docs / user / userguide / arcanist_lint_unit.diviner
blob6ecc9aaa3e4b089e37e8c092e58592dc3526f4cd
1 @title Arcanist User Guide: Customizing Lint, Unit Tests and Workflows
2 @group userguide
4 Explains how to build new classes to control how Arcanist behaves.
6 This is a configuration guide that helps you set up advanced features. If you're
7 just getting started, you don't need to look at this yet. Instead, start with
8 the @{article:Arcanist User Guide}.
10 = Overview =
12 Arcanist has some basic configuration options available in the `.arcconfig`
13 file (see @{article:Arcanist User Guide: Configuring a New Project}), but it
14 can't handle everything. If you want to customize Arcanist at a deeper level,
15 you need to build new classes. For instance:
17   - if you want to configure linters, or add new linters, you need to create a
18     new class which extends @{class@arcanist:ArcanistLintEngine}.
19   - if you want to integrate with a unit testing framework, you need to create a
20     new class which extends @{class@arcanist:ArcanistUnitTestEngine}.
21   - if you you want to change how workflows behave, or add new workflows, you
22     need to create a new class which extends
23     @{class@arcanist:ArcanistConfiguration}.
25 Arcanist works through a sort of dependency-injection approach. For example,
26 Arcanist does not run lint rules by default, but you can set `lint.engine`
27 in your `.arcconfig` to the name of a class which extends
28 @{class@arcanist:ArcanistLintEngine}. When running from inside your project,
29 Arcanist will load this class and call methods on it in order to run lint. To
30 make this work, you need to do three things:
32   - actually write the class;
33   - add the library where the class exists to your `.arcconfig`;
34   - add the class name to your `.arcconfig` as the **lint.engine**,
35     **unit.engine**, or **arcanist_configuration**.
37 = Create a libphutil Library =
39 If you haven't created a library for the class to live in yet, you need to do
40 that first. Follow the instructions in
41 @{article@phabcontrib:Adding New Classes}, then make the library loadable by
42 adding it to your `.arcconfig` like this:
44   {
45     // ...
46     "load" : [
47       // ...
48       "/path/to/my/library", // Absolute path
49       "support/arcanist",    // Relative path in this project
50       // ...
51     ]
52     // ...
53   }
55 You can either specify an absolute path, or a path relative to the project root.
56 When you run `arc list --trace`, you should see a message to the effect that
57 it has loaded your library.
59 For debugging or testing, you can also run Arcanist with the
60 `--load-phutil-library` flag:
62   arc --load-phutil-library=/path/to/library <command>
64 You can specify this flag more than once to load several libraries. Note that
65 if you use this flag, Arcanist will ignore any libraries listed in
66 `.arcconfig`.
68 = Use the Class =
70 This step is easy: just edit `.arcconfig` to specify your class name as
71 the appropriate configuration value.
73   {
74     // ...
75     "lint.engine" : "CustomArcanistLintEngine",
76     // ...
77   }
79 Now, when you run Arcanist in your project, it will invoke your class when
80 appropriate.
82 For lint and unit tests, you can also use the `--engine` flag override the
83 default engine:
85   arc lint --engine MyCustomArcanistLintEngine
87 This is mostly useful for debugging and testing.
89 = Next Steps =
91   - Learn how to reuse existing linters by reading
92     @{article:Arcanist User Guide: Customizing Existing Linters}.