{
    "componentChunkName": "component---src-templates-doc-tsx",
    "path": "/docs/3.9.x/en/development/styleguide/",
    "result": {"data":{"navigation":{"nodes":[{"section":"Getting started","entries":[{"frontmatter":{"title":"Installation","subtitle":"Installation of scm-manager","partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/installation/"}},{"frontmatter":{"title":"First Startup","subtitle":"Administration User Creation","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/first-startup/"}},{"frontmatter":{"title":"Migrate from v1 to v3","subtitle":"How to use the Migration-Wizard","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/migrate-scm-manager-from-v1/"}},{"frontmatter":{"title":"Migrate from v2 to v3","subtitle":"Changes in the configuration","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/migrate-scm-manager-from-v2/"}},{"frontmatter":{"title":"Import existing repositories","subtitle":"How to import existing repositories into SCM-Manager","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/import/"}},{"frontmatter":{"title":"Frequently Asked Questions","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/faq/"}},{"frontmatter":{"title":"Known Issues","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/known-issues/"}}]},{"section":"User-oriented","entries":[{"frontmatter":{"title":"Repository","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/repo/"}},{"frontmatter":{"title":"User","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/user/"}},{"frontmatter":{"title":"Groups","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/group/"}},{"frontmatter":{"title":"Administration","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/admin/"}},{"frontmatter":{"title":"Profile","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/profile/"}},{"frontmatter":{"title":"Notifications","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/notification/"}},{"frontmatter":{"title":"CLI Client","subtitle":null,"partiallyActive":true},"fields":{"slug":"/docs/3.9.x/en/user/cli/"}},{"frontmatter":{"title":"Shortcuts","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/user/shortcuts/"}}]},{"section":"Administration","entries":[{"frontmatter":{"title":"Base Directory","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/administration/basedirectory/"}},{"frontmatter":{"title":"Logging","subtitle":"Configuration and locations of SCM-Manager logging","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/administration/logging/"}},{"frontmatter":{"title":"SCM-Server Configuration","subtitle":"Various configuration options for the SCM-Server","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/administration/scm-server/"}},{"frontmatter":{"title":"Reverse Proxy","subtitle":"How to use SCM-Manager with common reverse proxies","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/administration/reverse-proxies/"}},{"frontmatter":{"title":"Caching for Working Directories","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/administration/workdir_caching/"}}]},{"section":"Development","entries":[{"frontmatter":{"title":"Intellij IDEA Configuration","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/intellij-idea-configuration/"}},{"frontmatter":{"title":"Building SCM-Manager from Source","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/build-from-source/"}},{"frontmatter":{"title":"Architecture overview","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/architecture-overview/"}},{"frontmatter":{"title":"Common pitfall occurred while developing the SCM V2","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/ui-common-pitfall/"}},{"frontmatter":{"title":"Permission Concept","subtitle":"Fine-grained permission for SCM-Manager v2","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/permission-concept/"}},{"frontmatter":{"title":"Decision Table","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/decision-table/"}},{"frontmatter":{"title":"Error Handling","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/error-handling/"}},{"frontmatter":{"title":"Styleguide","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/styleguide/"}},{"frontmatter":{"title":"Testing Guide","subtitle":"Howto write tests for SCM-Manager","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/testing-guide/"}},{"frontmatter":{"title":"Integration Tests","subtitle":"How to run integration tests","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/integration-tests/"}},{"frontmatter":{"title":"UI-Extensions","subtitle":"How to extend the SCM-Manager UI with plugins","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/ui-extensions/"}},{"frontmatter":{"title":"I18n","subtitle":"Howto do internationalization","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/i18n/"}},{"frontmatter":{"title":"Building Forms","subtitle":"Howto build forms for SCM-Manager","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/building-forms/"}},{"frontmatter":{"title":"Javadoc","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/javadoc/"}},{"frontmatter":{"title":"CLI Guidelines","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/cli-guideline/"}},{"frontmatter":{"title":"Definition of Done","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/definition-of-done/"}},{"frontmatter":{"title":"DOD for UI development","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/ui-dod/"}}]},{"section":"Plugin Development","entries":[{"frontmatter":{"title":"Create a plugin","subtitle":"Create a new SCM-Manager plugin","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/create/"}},{"frontmatter":{"title":"Migrate a v1 plugin","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/migrate-plugin-from-v1/"}},{"frontmatter":{"title":"Extension Points","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/extension-points/"}},{"frontmatter":{"title":"i18n for Plugins","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/i18n-for-plugins/"}},{"frontmatter":{"title":"Plugin Descriptor","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/plugin-descriptor/"}},{"frontmatter":{"title":"SCM-Manager v2 Plugin Development","subtitle":null,"partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/plugin-development/"}},{"frontmatter":{"title":"Publish","subtitle":"Publish your Plugin","partiallyActive":null},"fields":{"slug":"/docs/3.9.x/en/development/plugins/publish/"}}]}]},"versions":{"group":[{"fieldValue":"1.0.x"},{"fieldValue":"1.x"},{"fieldValue":"2.0.x"},{"fieldValue":"2.1.x"},{"fieldValue":"2.10.x"},{"fieldValue":"2.11.x"},{"fieldValue":"2.12.x"},{"fieldValue":"2.13.x"},{"fieldValue":"2.14.x"},{"fieldValue":"2.15.x"},{"fieldValue":"2.16.x"},{"fieldValue":"2.17.x"},{"fieldValue":"2.18.x"},{"fieldValue":"2.19.x"},{"fieldValue":"2.2.x"},{"fieldValue":"2.20.x"},{"fieldValue":"2.21.x"},{"fieldValue":"2.22.x"},{"fieldValue":"2.23.x"},{"fieldValue":"2.24.x"},{"fieldValue":"2.25.x"},{"fieldValue":"2.26.x"},{"fieldValue":"2.27.x"},{"fieldValue":"2.28.x"},{"fieldValue":"2.29.x"},{"fieldValue":"2.3.x"},{"fieldValue":"2.30.x"},{"fieldValue":"2.31.x"},{"fieldValue":"2.32.x"},{"fieldValue":"2.33.x"},{"fieldValue":"2.34.x"},{"fieldValue":"2.35.x"},{"fieldValue":"2.36.x"},{"fieldValue":"2.37.x"},{"fieldValue":"2.38.x"},{"fieldValue":"2.39.x"},{"fieldValue":"2.4.x"},{"fieldValue":"2.40.x"},{"fieldValue":"2.41.x"},{"fieldValue":"2.42.x"},{"fieldValue":"2.43.x"},{"fieldValue":"2.44.x"},{"fieldValue":"2.45.x"},{"fieldValue":"2.46.x"},{"fieldValue":"2.47.x"},{"fieldValue":"2.48.x"},{"fieldValue":"2.5.x"},{"fieldValue":"2.6.x"},{"fieldValue":"2.7.x"},{"fieldValue":"2.8.x"},{"fieldValue":"2.9.x"},{"fieldValue":"3.0.x"},{"fieldValue":"3.1.x"},{"fieldValue":"3.10.x"},{"fieldValue":"3.11.x"},{"fieldValue":"3.2.x"},{"fieldValue":"3.3.x"},{"fieldValue":"3.4.x"},{"fieldValue":"3.5.x"},{"fieldValue":"3.6.x"},{"fieldValue":"3.7.x"},{"fieldValue":"3.8.x"},{"fieldValue":"3.9.x"}]},"languages":{"group":[{"fieldValue":"de"},{"fieldValue":"en"}]},"markdownRemark":{"html":"<p>Starting with version 2 of SCM-Manager we have decided to change the code style and conform to more common rules. Furthermore we abandon the rule, that everything needs to have a javadoc description. Nonetheless we have decided against a \"big bang\" adaption of the new rule, because this would have lead to enourmous problems for merges from 1.x to 2.x.</p>\n<p>So whenever touching 1.x code you have to make the decision, whether it is appropriate to migrate some of the code you touch to the new style. Always keep in mind, that even slight changes may be dangerous becaus old code might not have a good test coverage.</p>\n<p>Also it is a good guide line to adapt Postel's law: <em>Be conservative in what you do, be liberal in what you accept from others.</em> So do not be the wise guy changing everything that does not fit to the rules below just because.</p>\n<h2 id=\"java\" style=\"position:relative;\"><a href=\"#java\" aria-label=\"java permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Java</h2>\n<p>Please mind the <a href=\"https://editorconfig.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">EditorConfig</a> file <code class=\"language-text\">.editorconfig</code> in the root of the SCM-Manager and the <a href=\"../intellij-idea-configuration\">configuration guide</a> for IntelliJ IDEA. There are plugins for a lot of IDEs and text editors.</p>\n<p>In the following, there are some rules we have come to value and that we would like to follow. Some are simple, others might need\nmore skill. If you feel overwhelmed by them, do not let them deter you. We love to support you in keeping these rules.</p>\n<ul>\n<li>Indentation with 2 spaces and no tabs (we have kept this rule from 1.x)</li>\n<li>Order of members:\n<ul>\n<li>public static fields</li>\n<li>private static fields</li>\n<li>public instant fields</li>\n<li>private instant fields</li>\n<li>constructors</li>\n<li>methods</li>\n</ul>\n</li>\n<li>No \"star imports\", that is no <code class=\"language-text\">import java.util.*</code></li>\n<li>One empty line between functions</li>\n<li>A space after keywords like <code class=\"language-text\">if</code>, <code class=\"language-text\">else</code>, <code class=\"language-text\">for</code>, <code class=\"language-text\">while</code>, <code class=\"language-text\">try</code>, and <code class=\"language-text\">catch</code>, between closing and opening parens after\nconditions and after semicolons, like this\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token function\">someCondition</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token function\">thisShouldBeDone</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token function\">somethingOtherCanHappen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\nor this\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">for</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">int</span> i <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span> i <span class=\"token operator\">&lt;</span> some<span class=\"token punctuation\">.</span><span class=\"token function\">length</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token operator\">++</span>i<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token function\">doSomethingWith</span><span class=\"token punctuation\">(</span>i<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n</li>\n<li>No separate lines for opening curly braces</li>\n<li>Though we will not define a maximum line length, you should break lines when they go beyond 120 characters or so\n<ul>\n<li>Long parameter lists in method or constructor definitions or calls should be consistently broken apart after each parameter</li>\n<li>There should not be two statements on a single line (apart from for or while loops)</li>\n<li>Closing brackets should be put on extra lines, when there is a line break after the matching opening braket</li>\n</ul>\n</li>\n<li>Names (for classes, constants, fields, methods, ...) should be pronounceable</li>\n<li>Try to enforce encapsulation\n<ul>\n<li>If possible, collections as return values should be immutable</li>\n<li>When modifying a collection in another object, do not \"get\" the collection and modify it but add an explicit method\nin the object holding the collection for this.</li>\n</ul>\n</li>\n<li>Use Lombock annotations where appropriate. That is\n<ul>\n<li>Getter, setter and constructor annotations in data classes (do not use this in classes used for business logic)</li>\n<li>Data or value annotations to reveal intent</li>\n<li>Slf4j annotation can be used as a replacement for explicit logger constant creation</li>\n</ul>\n</li>\n<li>We do not have strict logging rules, yet. Just some guidelines:\n<ul>\n<li>Use Slf4j's <code class=\"language-text\">LoggerFactory</code> with the class name you are in to create the <code class=\"language-text\">Logger</code> as a <code class=\"language-text\">static final</code> constant and\nnamed <code class=\"language-text\">LOG</code> or simply use the <code class=\"language-text\">Slf4j</code> annotation by Lombok (but not both in one class)</li>\n<li>The log levels are\n<ul>\n<li><code class=\"language-text\">error</code> for failures an administrator should take care of immediately</li>\n<li><code class=\"language-text\">warn</code> for failed processes that might lead to inconsistencies or unexpected behaviour like errors accessing external\nsystems or other services</li>\n<li><code class=\"language-text\">info</code> for events that might be of interest in a daily business (like a user that has been blocked, a new access token\nthat has been created, a long running task that has been started or finished)</li>\n<li><code class=\"language-text\">debug</code> for coarse information about internal processes (a pull request that has been closed, an event that has been\ntriggered, a mail that has been sent)</li>\n<li><code class=\"language-text\">trace</code> to reproduce workflows</li>\n</ul>\n</li>\n<li>Think about using Micrometer metrics if possible</li>\n</ul>\n</li>\n<li>Longer call chains (like when using Java's stream API or builder patterns) should be formatted in a way, that the \"flow\"\nis recognizable. For this there should be a line break before each new invocation like this:\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\">myCollection<span class=\"token punctuation\">.</span><span class=\"token function\">stream</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">.</span><span class=\"token function\">filter</span><span class=\"token punctuation\">(</span>item<span class=\"token operator\">::</span><span class=\"token function\">isApplicable</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">.</span><span class=\"token function\">map</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">this</span><span class=\"token operator\">::</span><span class=\"token function\">transform</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">.</span><span class=\"token function\">forEach</span><span class=\"token punctuation\">(</span>\n    item <span class=\"token operator\">-></span> <span class=\"token function\">processThisItem</span><span class=\"token punctuation\">(</span>item<span class=\"token punctuation\">,</span> some<span class=\"token punctuation\">,</span> more<span class=\"token punctuation\">,</span> input<span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n</li>\n<li>When defining APIs, evolvability is key. Often it is a good practice to use classes to enclose parameters for or return values\nof methods, so that parameters can be set independently. For example, if an interface can be implemented in (another) plugin,\nuse a construct like this:\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">interface</span> <span class=\"token class-name\">MyReceiver</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token class-name\">ComputationResult</span> <span class=\"token function\">compute</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">ComputationInput</span> input<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token annotation punctuation\">@Data</span>\n<span class=\"token keyword\">class</span> <span class=\"token class-name\">ComputationInput</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">private</span> <span class=\"token class-name\">String</span> textInput<span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">private</span> <span class=\"token keyword\">int</span> numberInput<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token annotation punctuation\">@Value</span>\n<span class=\"token keyword\">class</span> <span class=\"token class-name\">ComputationResult</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">private</span> <span class=\"token class-name\">String</span> textOutput<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\nThis way it is possible, to add further optional input and output parameters without getting build breakers in implementing\nclasses (that can lead to runtime errors when implemented in other plugins).</li>\n<li>Scope (visibility) should be as narrow as possible. Try to use private or package protected (default) scope as often as possible.\nThis does not only apply for methods and fields inside of classes, but for classes, interfaces and enums, too.</li>\n<li>The qualifier <code class=\"language-text\">this</code> should only be used if necessary (that is, if the field has to be distinguished from another variable\nin the current scope with the same name, which should be avoided apart from constructors)</li>\n<li>Normally, variables and parameters should not explicitly be set <code class=\"language-text\">final</code> (mind, this does not account to fields; these should\nbe marked final if it is not explicitly intended otherwise)</li>\n</ul>\n<h2 id=\"javascript\" style=\"position:relative;\"><a href=\"#javascript\" aria-label=\"javascript permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JavaScript</h2>\n<p>Take a look at our styleguide using <code class=\"language-text\">yarn serve</code> in <code class=\"language-text\">/scm-ui/ui-styles</code> directory.</p>","description":"Starting with version 2 of SCM-Manager we have decided to change the code style and conform to more common rules. Furthermore we abandon the rule, that…","tableOfContents":"<ul>\n<li><a href=\"#java\">Java</a></li>\n<li><a href=\"#javascript\">JavaScript</a></li>\n</ul>","frontmatter":{"title":"Styleguide","subtitle":null,"displayToc":null,"description":null,"keywords":null,"image":null}}},"pageContext":{"slug":"/docs/3.9.x/en/development/styleguide/","version":"3.9.x","latestVersion":"3.11.x","latestPageVersion":"3.11.x","language":"en","relativePath":"/development/styleguide/","canonicalPath":"/docs/latest/en/development/styleguide/","latestRootPath":"/docs/3.11.x/en/"}},
    "staticQueryHashes": ["1973669194","2742214048","2956773653","2957019495","698804963"]}