9 | 10 | {{ page.title }} 11 | 12 |
13 | 14 | 15 |16 | Welcome to Code Catalog! If you are reading this, it means that we've launched. 17 |
18 | 19 |20 | Stay up to date by subscribing to our Atom (RSS-like) feed or our newsletter. 21 |
22 |├── CNAME ├── .gitignore ├── _sass └── custom │ └── custom.scss ├── _languages ├── Go.md ├── C++.md ├── Java.md ├── Ruby.md ├── Rust.md ├── Python.md └── TypeScript.md ├── _tags ├── aws.md ├── cli.md ├── dao.md ├── diff.md ├── dsl.md ├── sql.md ├── trie.md ├── chess.md ├── cloud.md ├── graph.md ├── builder.md ├── parsing.md ├── spinner.md ├── visitor.md ├── algorithm.md ├── bitboard.md ├── decorator.md ├── strategy.md ├── tokenizer.md ├── data-access.md ├── test-helper.md ├── token-bucket.md ├── data-structure.md ├── rate-limiting.md ├── spell-checking.md ├── test-framework.md ├── connection-pool.md ├── leader-election.md ├── template-method.md ├── status-reporting.md ├── chaos-engineering.md └── infrastructure-as-code.md ├── _projects ├── bat.md ├── buck.md ├── jest.md ├── httpie.md ├── puppet.md ├── scylla.md ├── aws-cdk.md ├── aws-cli.md ├── homebrew.md ├── protobuf.md ├── stockfish.md ├── terraform.md ├── zookeeper.md ├── error-prone.md ├── firecracker.md ├── vscode.md ├── chaos-monkey.md └── did_you_mean.md ├── blog.html ├── .github └── ISSUE_TEMPLATE │ ├── feature-request.md │ ├── article-improvement.md │ ├── bug.md │ └── new-example-proposal.md ├── _articles ├── TEST.md ├── bat-decorations.md ├── jest-test-sequencer.md ├── httpie-status-reporting.md ├── puppet-connection-pool.md ├── jest-diff.md ├── did_you_mean-spell-checking.md ├── vscode-skip-list.md ├── buck-artifact-cache-decorators.md ├── chaos-monkey-store.md ├── protobuf-tokenizer.md ├── aws-cdk-template-diff.md ├── error-prone-test-helper.md └── zookeeper-trie.md ├── _includes ├── footer_custom.html ├── need-your-help.html ├── article-meta.html ├── article-list.html └── nav.html ├── 404.html ├── Gemfile ├── _posts ├── 2021-07-16-welcome.html ├── 2021-08-09-puppet-connection-pool.html ├── 2021-09-25-scylla-raft-leader-election.md ├── 2021-08-09-jest-test-sequencer.html ├── 2021-08-31-jest-diff.md ├── 2021-09-15-vscode-skip-list.md ├── 2021-08-12-protobuf-tokenizer.html ├── 2021-08-05-firecracker-rate-limiting.html ├── 2021-08-13-buck-artifact-cache-decorator.md ├── 2021-08-26-did_you_mean-spell-checking.html └── 2021-09-09-puppet-graph-algorithms.md ├── CONTRIBUTING.md ├── ARTICLE_TEMPLATE.md ├── _config.yml ├── README.md ├── index.md ├── Gemfile.lock └── _layouts └── default.html /CNAME: -------------------------------------------------------------------------------- 1 | codecatalog.org -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | .sass-cache 3 | .jekyll-cache 4 | .jekyll-metadata 5 | vendor 6 | -------------------------------------------------------------------------------- /_sass/custom/custom.scss: -------------------------------------------------------------------------------- 1 | .main-content table a { 2 | white-space: normal; 3 | } 4 | -------------------------------------------------------------------------------- /_languages/Go.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Go 4 | --- 5 | 6 | {% include article-list.html name="Go" language="Go" %} 7 | -------------------------------------------------------------------------------- /_languages/C++.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: C++ 4 | --- 5 | 6 | {% include article-list.html name="C++" language="C++" %} 7 | -------------------------------------------------------------------------------- /_languages/Java.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Java 4 | --- 5 | 6 | {% include article-list.html name="Java" language="Java" %} 7 | -------------------------------------------------------------------------------- /_languages/Ruby.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Ruby 4 | --- 5 | 6 | {% include article-list.html name="Ruby" language="Ruby" %} 7 | -------------------------------------------------------------------------------- /_languages/Rust.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Rust 4 | --- 5 | 6 | {% include article-list.html name="Rust" language="Rust" %} 7 | -------------------------------------------------------------------------------- /_tags/aws.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: aws 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'aws'" tag="aws" %} 7 | -------------------------------------------------------------------------------- /_tags/cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: cli 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'cli'" tag="cli" %} 7 | -------------------------------------------------------------------------------- /_tags/dao.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: dao 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'dao'" tag="dao" %} 7 | -------------------------------------------------------------------------------- /_tags/diff.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: diff 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'diff'" tag="diff" %} 7 | -------------------------------------------------------------------------------- /_tags/dsl.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: dsl 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'dsl'" tag="dsl" %} 7 | -------------------------------------------------------------------------------- /_tags/sql.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: sql 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'sql'" tag="sql" %} 7 | -------------------------------------------------------------------------------- /_tags/trie.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: trie 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'trie'" tag="trie" %} 7 | -------------------------------------------------------------------------------- /_languages/Python.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Python 4 | --- 5 | 6 | {% include article-list.html name="Python" language="Python" %} 7 | -------------------------------------------------------------------------------- /_tags/chess.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: chess 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'chess'" tag="chess" %} 7 | -------------------------------------------------------------------------------- /_tags/cloud.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: cloud 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'cloud'" tag="cloud" %} 7 | -------------------------------------------------------------------------------- /_tags/graph.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: graph 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'graph'" tag="graph" %} 7 | -------------------------------------------------------------------------------- /_projects/bat.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Bat 4 | key: bat 5 | --- 6 | 7 | {% include article-list.html name="Bat" project-key="bat" %} 8 | -------------------------------------------------------------------------------- /_projects/buck.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Buck 4 | key: buck 5 | --- 6 | 7 | {% include article-list.html name="Buck" project-key="buck" %} 8 | -------------------------------------------------------------------------------- /_projects/jest.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Jest 4 | key: jest 5 | --- 6 | 7 | {% include article-list.html name="Jest" project-key="jest" %} 8 | -------------------------------------------------------------------------------- /_tags/builder.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: builder 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'builder'" tag="builder" %} 7 | -------------------------------------------------------------------------------- /_tags/parsing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: parsing 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'parsing'" tag="parsing" %} 7 | -------------------------------------------------------------------------------- /_tags/spinner.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: spinner 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'spinner'" tag="spinner" %} 7 | -------------------------------------------------------------------------------- /_tags/visitor.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: visitor 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'visitor'" tag="visitor" %} 7 | -------------------------------------------------------------------------------- /_languages/TypeScript.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: TypeScript 4 | --- 5 | 6 | {% include article-list.html name="TypeScript" language="TypeScript" %} 7 | -------------------------------------------------------------------------------- /_tags/algorithm.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: algorithm 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'algorithm'" tag="algorithm" %} 7 | -------------------------------------------------------------------------------- /_tags/bitboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: bitboard 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'bitboard'" tag="bitboard" %} 7 | -------------------------------------------------------------------------------- /_tags/decorator.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: decorator 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'decorator'" tag="decorator" %} 7 | -------------------------------------------------------------------------------- /_tags/strategy.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: strategy 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'strategy'" tag="strategy" %} 7 | -------------------------------------------------------------------------------- /_tags/tokenizer.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: tokenizer 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'tokenizer'" tag="tokenizer" %} 7 | -------------------------------------------------------------------------------- /blog.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: "Blog" 4 | permalink: blog 5 | --- 6 | 7 | {% for post in site.posts %} 8 | {{ post.content }} 9 | {% endfor %} -------------------------------------------------------------------------------- /_projects/httpie.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: HTTPie 4 | key: httpie 5 | --- 6 | 7 | {% include article-list.html name="HTTPie" project-key="httpie" %} 8 | -------------------------------------------------------------------------------- /_projects/puppet.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Puppet 4 | key: puppet 5 | --- 6 | 7 | {% include article-list.html name="Puppet" project-key="puppet" %} 8 | -------------------------------------------------------------------------------- /_projects/scylla.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Scylla 4 | key: scylla 5 | --- 6 | 7 | {% include article-list.html name="Scylla" project-key="scylla" %} 8 | -------------------------------------------------------------------------------- /_projects/aws-cdk.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: AWS CDK 4 | key: aws-cdk 5 | --- 6 | 7 | {% include article-list.html name="AWS CDK" project-key="aws-cdk" %} 8 | -------------------------------------------------------------------------------- /_projects/aws-cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: AWS CLI 4 | key: aws-cli 5 | --- 6 | 7 | {% include article-list.html name="AWS CLI" project-key="aws-cli" %} 8 | -------------------------------------------------------------------------------- /_tags/data-access.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: data-access 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'data-access'" tag="data-access" %} 7 | -------------------------------------------------------------------------------- /_tags/test-helper.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: test-helper 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'test-helper'" tag="test-helper" %} 7 | -------------------------------------------------------------------------------- /_projects/homebrew.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Homebrew 4 | key: homebrew 5 | --- 6 | 7 | {% include article-list.html name="Homebrew" project-key="homebrew" %} 8 | -------------------------------------------------------------------------------- /_projects/protobuf.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Protobuf 4 | key: protobuf 5 | --- 6 | 7 | {% include article-list.html name="Protobuf" project-key="protobuf" %} 8 | -------------------------------------------------------------------------------- /_tags/token-bucket.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: token-bucket 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'token-bucket'" tag="token-bucket" %} 7 | -------------------------------------------------------------------------------- /_projects/stockfish.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Stockfish 4 | key: stockfish 5 | --- 6 | 7 | {% include article-list.html name="Stockfish" project-key="stockfish" %} 8 | -------------------------------------------------------------------------------- /_projects/terraform.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Terraform 4 | key: terraform 5 | --- 6 | 7 | {% include article-list.html name="Terraform" project-key="terraform" %} 8 | -------------------------------------------------------------------------------- /_projects/zookeeper.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: ZooKeeper 4 | key: zookeeper 5 | --- 6 | 7 | {% include article-list.html name="ZooKeeper" project-key="zookeeper" %} 8 | -------------------------------------------------------------------------------- /_tags/data-structure.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: data-structure 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'data-structure'" tag="data-structure" %} 7 | -------------------------------------------------------------------------------- /_tags/rate-limiting.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: rate-limiting 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'rate-limiting'" tag="rate-limiting" %} 7 | -------------------------------------------------------------------------------- /_tags/spell-checking.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: spell-checking 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'spell-checking'" tag="spell-checking" %} 7 | -------------------------------------------------------------------------------- /_tags/test-framework.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: test-framework 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'test-framework'" tag="test-framework" %} 7 | -------------------------------------------------------------------------------- /_projects/error-prone.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: ErrorProne 4 | key: error-prone 5 | --- 6 | 7 | {% include article-list.html name="ErrorProne" project-key="error-prone" %} 8 | -------------------------------------------------------------------------------- /_tags/connection-pool.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: connection-pool 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'connection-pool'" tag="connection-pool" %} 7 | -------------------------------------------------------------------------------- /_tags/leader-election.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: leader-election 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'leader-election'" tag="leader-election" %} 7 | -------------------------------------------------------------------------------- /_tags/template-method.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: template-method 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'template-method'" tag="template-method" %} 7 | -------------------------------------------------------------------------------- /_projects/firecracker.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Firecracker 4 | key: firecracker 5 | --- 6 | 7 | {% include article-list.html name="Firecracker" project-key="firecracker" %} 8 | -------------------------------------------------------------------------------- /_projects/vscode.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Visual Studio Code 4 | key: vscode 5 | --- 6 | 7 | {% include article-list.html name="Visual Studio Code" project-key="vscode" %} 8 | -------------------------------------------------------------------------------- /_tags/status-reporting.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: status-reporting 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'status-reporting'" tag="status-reporting" %} 7 | -------------------------------------------------------------------------------- /_projects/chaos-monkey.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Chaos Monkey 4 | key: chaos-monkey 5 | --- 6 | 7 | {% include article-list.html name="Chaos Monkey" project-key="chaos-monkey" %} 8 | -------------------------------------------------------------------------------- /_projects/did_you_mean.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: did_you_mean 4 | key: did_you_mean 5 | --- 6 | 7 | {% include article-list.html name="did_you_mean" project-key="did_you_mean" %} 8 | -------------------------------------------------------------------------------- /_tags/chaos-engineering.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: chaos-engineering 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'chaos-engineering'" tag="chaos-engineering" %} 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project. 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /_tags/infrastructure-as-code.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: infrastructure-as-code 4 | --- 5 | 6 | {% include article-list.html name="Tagged with 'infrastructure-as-code'" tag="infrastructure-as-code" %} 7 | -------------------------------------------------------------------------------- /_articles/TEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test Article [TestLanguage]" 3 | layout: default 4 | nav_exclude: true 5 | 6 | status: DRAFT 7 | language: Test 8 | project: 9 | name: Test 10 | key: Test 11 | home-page: https://github.com/example/example 12 | tags: [test-tag-1] 13 | --- 14 | 15 | {% include article-meta.html article=page %} 16 | 17 | ## Content 18 | 19 | Test article, excluded from navigation. 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/article-improvement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Article Improvement 3 | about: Suggest an improvement to an existing article or report an issue with it. 4 | title: '' 5 | labels: article improvement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 13 | 14 | **Which article?** 15 | 16 | ... 17 | 18 | **How can it be improved?** 19 | 20 | ... 21 | 22 | -------------------------------------------------------------------------------- /_includes/footer_custom.html: -------------------------------------------------------------------------------- 1 | {% if page.id contains "/articles/" or page.id contains "/2021/" %} 2 | 10 | {% endif %} 11 | 12 |
{{ site.footer_content }}
13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug. 4 | title: "" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 15 | 16 | **Describe the bug you encountered:** 17 | 18 | ... 19 | 20 | **What did you expect to happen instead?** 21 | 22 | ... 23 | 24 | -------------------------------------------------------------------------------- /_includes/need-your-help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Help Code Catalog grow: suggest your favorite code or weight in on open article proposals. 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /404.html 3 | layout: default 4 | --- 5 | 6 | 19 | 20 |Page not found :(
24 |The requested page could not be found.
25 |16 | Welcome to Code Catalog! If you are reading this, it means that we've launched. 17 |
18 | 19 |20 | Stay up to date by subscribing to our Atom (RSS-like) feed or our newsletter. 21 |
22 |16 | A new article about connection pools in Puppet has been added to the catalog. 17 |
18 | 19 |20 | The code is written in Ruby. Its goal is to avoid making a new TCP connection and SSL handshake for each request by reusing persistent connections. 21 |
22 | 23 |24 | Puppet - HTTP Connection Pool 25 |
26 |16 | A new article about ordering tests in Jest has been added to the catalog. 17 |
18 | 19 |20 | The code is written in TypeScript and attempts to improve user-perceived responsiveness and speed of the test run. It's achieved by prioritizing tests that failed during the last run and slower tests. 21 |
22 | 23 |24 | Jest - Test Sequencer 25 |
26 |16 | A new article about tokenizing Protocol Buffers has been added to the catalog. 17 |
18 | 19 |20 | This code was written in C++ back in 2008, and it's still used very widely at Google and outside. What stands out about it are how thoroughly the design decisions are documented and the personal tone of the comments. 21 |
22 | 23 |24 | Protocol Buffers - Tokenizer 25 |
26 |16 | A new article about rate limiting operations and bandwidth in Firecracker has been added to the catalog. 17 |
18 | 19 |20 | The implementations is based on the Token Bucket algorithm. The code is written in Rust. It's clear, simple and wonderfully documented. 21 |
22 | 23 |24 | Firecracker - Rate Limiting 25 |
26 |16 | A new article about decorators for artifact caches in Buck, a multi-language build system developed and used by Facebook, has been added to the catalog. 17 |
18 | 19 |20 | The code is written in Java. It uses the classical Decorator design pattern to add behavior to individual cache instances without affecting the behavior of other objects from the same class. 21 |
22 | 23 |24 | Buck - Artifact Cache Decorators 25 |
26 |16 | A new article about using spell-checking to correct typos in Ruby code with did_you_mean gem has been added to the catalog. The whole existence of this gem sparks controversy about static vs dynamic languages. 17 |
18 | 19 |20 | We also highly recommend listening to the gem author's talk about it. 21 |
22 | 23 |24 | did_you_mean - Correcting Typos in Ruby 25 |
26 || Title | 10 |Project | 11 |Language | 12 |Tags | 13 |
|---|---|---|---|
| 21 | {{ article.short-title }} 22 | | 23 |24 | {{ article.project.name }} 25 | | 26 |27 | {{ article.language }} 28 | | 29 |30 | {%- for tag in article.tags -%} 31 | #{{ tag }} 32 | {{ " " }} 33 | {%- endfor -%} 34 | | 35 |
The diagnostics expected from compiling the file are inferred from the file contents. For 108 | * each line of the test file that contains the bug marker pattern "// BUG: Diagnostic contains: 109 | * foo", we expect to see a diagnostic on that line containing "foo". For each line of the test 110 | * file that does not contain the bug marker pattern, we expect no diagnostic to be 111 | * generated. You can also use "// BUG: Diagnostic matches: X" in tandem with {@code 112 | * expectErrorMessage("X", "foo")} to allow you to programmatically construct the error message. 113 | * 114 | * @param path a path for the source file 115 | * @param lines the content of the source file 116 | */ 117 | public CompilationTestHelper addSourceLines(String path, String... lines) { 118 | this.sources.add(forSourceLines(path, lines)); 119 | return this; 120 | } 121 | 122 | /** 123 | * Adds a source file to the test compilation, from an existing resource file. 124 | * 125 | *
See {@link #addSourceLines} for how expected diagnostics should be specified.
126 | *
127 | * @param path the path to the source file
128 | */
129 | public CompilationTestHelper addSourceFile(String path) {
130 | this.sources.add(forResource(clazz, path));
131 | return this;
132 | }
133 | ```
134 |
135 | The main [`doTest` method](https://github.com/google/error-prone/blob/c601758e81723a8efc4671726b8363be7a306dce/test_helpers/src/main/java/com/google/errorprone/CompilationTestHelper.java#L293-L346) that compiles the supplied code and compares the output to the expectations:
136 | ```java
137 | /** Performs a compilation and checks that the diagnostics and result match the expectations. */
138 | public void doTest() {
139 | checkState(!sources.isEmpty(), "No source files to compile");
140 | checkState(!run, "doTest should only be called once");
141 | this.run = true;
142 | Result result = compile();
143 | for (Diagnostic extends JavaFileObject> diagnostic : diagnosticHelper.getDiagnostics()) {
144 | if (diagnostic.getCode().contains("error.prone.crash")) {
145 | fail(diagnostic.getMessage(Locale.ENGLISH));
146 | }
147 | }
148 | if (expectNoDiagnostics) {
149 | List