Repository Analysis

terrastruct/d2

D2 is a modern diagram scripting language that turns text to diagrams.

0.5 Likely human-written View on GitHub
0.5
Adjusted Score
0.5
Raw Score
100%
Time Factor
2026-04-24
Last Push
24,004
Stars
Go
Language
1,118,022
Lines of Code
2031
Files
226
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 0HIGH 0MEDIUM 145LOW 81

Pattern Findings

226 matches across 6 categories. Click a row to expand file-level details.

Decorative Section Separators141 hits · 508 pts
SeverityFileLineSnippet
MEDIUMlib/shape/shape_oval.go52 // ┌──────────────────* ┬
MEDIUMlib/shape/shape_oval.go54 // │ *┌───────────┤ │ ┬
MEDIUMlib/shape/shape_oval.go57 // *──────┴───────────┼ ┴ ┴
MEDIUMlib/shape/shape_oval.go58 // ├────────rx────────┤
MEDIUMlib/shape/shape.go197// . ┌────r─────────────────────────┐
MEDIUMlib/shape/shape.go208// . └──────xxxxxxxxxxxxxx──────────┘
MEDIUMlib/label/label.go562 // ┌────────────────────┐ ┬ | ┌─┬─┐
MEDIUMlib/label/label.go563 // │ │ │ | │ │ │ ┌───────────┬───────────┐
MEDIUMlib/label/label.go568 // └────────────────────┘ │ ┴ ┬ | │ │ │ └───────────┴───────────┘
MEDIUMlib/label/label.go570 // offset│ │label padding | ├──────────────────┤
MEDIUMlib/label/label.go572 // ┌──────────────────────┐ │ ┬ ┴ | ├───────────┼───────────┤
MEDIUMlib/label/label.go574 // ├─────edge─center──────┤ ┴ ┼stroke width | label padding
MEDIUMlib/label/label.go576 // └──────────────────────┘ ┴ | stroke width
MEDIUMlib/pptx/pptx.go115 // ┌──────────────────────────────────────────────────┐ ─┬─
MEDIUMlib/pptx/pptx.go117 // ├──┬────────────────────────────────────────────┬──┤ │ ─┬─
MEDIUMlib/pptx/pptx.go127 // └──┴────────────────────────────────────────────┴──┘ ─┴─ ─┴─
MEDIUMlib/pptx/pptx.go128 // ├────────────────────SLIDE WIDTH───────────────────┤
MEDIUMlib/pptx/pptx.go129 // ├─────────────────IMAGE WIDTH────────────────┤
MEDIUMd2layouts/d2layouts.go109 // ┌grid(g.Root)───────────────────┐ ┌grid(g.Root)───────────────────┐
MEDIUMd2layouts/d2layouts.go110 // │ ┌────┐ ┌curr───────────┐ │ │ ┌────┐ │
MEDIUMd2layouts/d2layouts.go113 // │ │ ├──────┼C─┼──┼───►│ │ │ │ │ │ │ │
MEDIUMd2layouts/d2layouts.go115 // │ └────┘ └───────────────┘ │ │ └────┘ │
MEDIUMd2layouts/d2layouts.go116 // └───────────────────────────────┘ └───────────────────────────────┘
MEDIUMd2layouts/d2layouts.go177 // ┌grid(g.Root)───────────────────┐ ┌grid(g.Root)───────────────────┐
MEDIUMd2layouts/d2layouts.go178 // │ ┌────┐ ┌curr───────────┐ │ │ ┌────┐ ┌curr───────────┐ │
MEDIUMd2layouts/d2layouts.go181 // │ │ ├──────┼C─┼──┼───►│ │ │ │ │ │ │ │ │ │
MEDIUMd2layouts/d2layouts.go183 // │ └────┘ └───────────────┘ │ │ └────┘ └───────────────┘ │
MEDIUMd2layouts/d2layouts.go184 // └───────────────────────────────┘ └───────────────────────────────┘
MEDIUMd2layouts/d2grid/layout.go326 // . ┌A──────────────┐ ┌B──┐ ┌C─────────┐ ┌D────────┐ ┌E────────────────┐
MEDIUMd2layouts/d2grid/layout.go327 // . └───────────────┘ │ │ │ │ │ │ │ │
MEDIUMd2layouts/d2grid/layout.go328 // . │ │ └──────────┘ │ │ │ │
MEDIUMd2layouts/d2grid/layout.go329 // . │ │ │ │ └─────────────────┘
MEDIUMd2layouts/d2grid/layout.go331 // . └─────────┘
MEDIUMd2layouts/d2grid/layout.go333 // . ┌A─────────────┐ ┌B──┐ ┌C─────────┐ ┌D────────┐ ┌E────────────────┐
MEDIUMd2layouts/d2grid/layout.go338 // . └──────────────┘ └───┘ └──────────┘ └─────────┘ └─────────────────┘
MEDIUMd2layouts/d2grid/layout.go379 // . ┌A─────────────┐ ┌B──┐ ┌C─────────┐ ┬ maxHeight(A,B,C)
MEDIUMd2layouts/d2grid/layout.go383 // . └──────────────┘ └───┘ └──────────┘ ┴
MEDIUMd2layouts/d2grid/layout.go384 // . ┌D────────┬────┐ ┌E────────────────┐ ┬ maxHeight(D,E)
MEDIUMd2layouts/d2grid/layout.go389 // . └─────────┴────┘ └─────────────────┘ ┴
MEDIUMd2layouts/d2grid/layout.go427 // . ┌A─────────────┐ ┌B──┐ ┌C─────────┐ ┬ maxHeight(A,B,C)
MEDIUMd2layouts/d2grid/layout.go431 // . └──────────────┘ └───┘ └──────────┘ ┴
MEDIUMd2layouts/d2grid/layout.go432 // . ┌D────────┐ ┌E────────────────┐ ┬ maxHeight(D,E)
MEDIUMd2layouts/d2grid/layout.go437 // . └─────────┘ └─────────────────┘ ┴
MEDIUMd2layouts/d2grid/layout.go470 // . ├maxWidth(A,B)─┤ ├maxW(C,D)─┤ ├maxWidth(E)──────┤
MEDIUMd2layouts/d2grid/layout.go471 // . ┌A─────────────┐ ┌C─────────┐ ┌E────────────────┐
MEDIUMd2layouts/d2grid/layout.go473 // . │ │ └──────────┘ │ │
MEDIUMd2layouts/d2grid/layout.go474 // . └──────────────┘ ┌D─────────┐ ├ ─ ─ ─ ─ ─ ─ ─ ─ ┤
MEDIUMd2layouts/d2grid/layout.go475 // . ┌B─────────────┐ │ │ │ │
MEDIUMd2layouts/d2grid/layout.go479 // . └──────────────┘ └──────────┘ └─────────────────┘
MEDIUMd2layouts/d2grid/layout.go516 // . ├maxWidth(A,B)─┤ ├maxW(C,D)─┤ ├maxWidth(E)──────┤
MEDIUMd2layouts/d2grid/layout.go517 // . ┌A─────────────┐ ┌C─────────┐ ┌E────────────────┐
MEDIUMd2layouts/d2grid/layout.go518 // . └──────────────┘ │ │ │ │
MEDIUMd2layouts/d2grid/layout.go519 // . ┌B──┬──────────┐ └──────────┘ │ │
MEDIUMd2layouts/d2grid/layout.go520 // . │ │ ┌D────────┬┐ └─────────────────┘
MEDIUMd2layouts/d2grid/layout.go523 // . └───┴──────────┘ │ │
MEDIUMd2layouts/d2grid/layout.go525 // . └─────────┴┘
MEDIUMd2layouts/d2grid/layout.go649 // . A │ B C D │ E ┌D───────────┐
MEDIUMd2layouts/d2grid/layout.go650 // . A B │ C │ D E └────────────┘
MEDIUMd2layouts/d2grid/layout.go651 // . A │ B C │ D E ┌E───────────┐
MEDIUMd2layouts/d2grid/layout.go652 // . A │ B │ C D E └────────────┘
81 more matches not shown…
Fake / Example Data34 hits · 40 pts
SeverityFileLineSnippet
LOWe2etests/markdowntest.md72> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
LOWe2etests/markdowntest.md72> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
LOWe2etests/markdowntest.md81> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
LOWe2etests/markdowntest.md81> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
LOWe2etests/markdowntest.md164- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
LOWe2etests/markdowntest.md164- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
LOWe2etests/markdowntest.md172- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
LOWe2etests/markdowntest.md172- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
LOWe2etests/markdowntest.md1821. This is a list item with two paragraphs. Lorem ipsum dolor
LOWe2etests/markdowntest.md200 only required to indent the first line. Lorem ipsum dolor
LOWe2etests/stable_test.go10201. This is a list item with two paragraphs. Lorem ipsum dolor
LOWe2etests/stable_test.go1038 only required to indent the first line. Lorem ipsum dolor
LOWe2etests/stable_test.go1073 Lorem ipsum dolor
LOWe2etests/stable_test.go1076 Lorem ipsum dolor
LOWe2etests/stable_test.go1362Lorem ipsum dolor sit amet, consectetur adipiscing elit, ` + `
LOWe2etests/stable_test.go1362Lorem ipsum dolor sit amet, consectetur adipiscing elit, ` + `
LOWe2etests/stable_test.go1373Lorem ipsum dolor sit amet, consectetur adipiscing elit,\
LOWe2etests/stable_test.go1373Lorem ipsum dolor sit amet, consectetur adipiscing elit,\
LOW…testdata/stable/giant_markdown_test/elk/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
LOW…testdata/stable/giant_markdown_test/elk/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
LOW…stdata/stable/giant_markdown_test/dagre/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
LOW…stdata/stable/giant_markdown_test/dagre/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
LOW…estdata/stable/md_backslash_newline/elk/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore e
LOW…estdata/stable/md_backslash_newline/elk/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore e
LOW…tdata/stable/md_backslash_newline/dagre/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore e
LOW…tdata/stable/md_backslash_newline/dagre/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore e
LOW…s/testdata/stable/md_2space_newline/elk/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore e
LOW…s/testdata/stable/md_2space_newline/elk/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore e
LOW…testdata/stable/md_2space_newline/dagre/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore e
LOW…testdata/stable/md_2space_newline/dagre/board.exp.json85 "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore e
LOWe2etests/testdata/stable/li4/elk/board.exp.json43 "label": "\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be inden
LOWe2etests/testdata/stable/li4/dagre/board.exp.json43 "label": "\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be inden
LOWe2etests/testdata/stable/br/elk/board.exp.json43 "label": "# Headline 1\n## Headline 2\nLorem ipsum dolor\n<br />\n## Headline 3\nLorem ipsum dolor\n<br />\n<br />
LOWe2etests/testdata/stable/br/dagre/board.exp.json43 "label": "# Headline 1\n## Headline 2\nLorem ipsum dolor\n<br />\n## Headline 3\nLorem ipsum dolor\n<br />\n<br />
Over-Commented Block43 hits · 39 pts
SeverityFileLineSnippet
LOWinstall.sh1#!/bin/sh
LOWinstall.sh361
LOWinstall.sh381#
LOWd2parser/parse.go21type ParseOptions struct {
LOWd2parser/parse.go341}
LOWd2ir/compile.go401 for i, p := range substitution.Path {
LOWd2plugin/exec.go21// execPlugin uses the binary at pathname with the plugin protocol to implement
LOWd2oracle/edit.go361 imported := false
LOWd2ast/d2ast.go1// TODO: Remove boxes and cleanup like d2ir
LOWd2ast/d2ast.go781
LOWd2chaos/d2chaos_test.go21)
LOWci/release/gen_install.sh1#!/bin/sh
LOWci/release/gen_template_lib.sh1#!/bin/sh
LOWci/release/template/scripts/lib.sh1#!/bin/sh
LOWci/release/aws/ensure.sh521# To run a pure MSYS2 shell:
LOWlib/shape/shape_oval.go41 paddedHeight := height + paddingY*math.Sin(theta)
LOWlib/shape/shape.go181 },
LOWlib/textmeasure/textmeasure.go41
LOWlib/textmeasure/textmeasure.go61// Newlines, tabs and carriage returns are supported.
LOWlib/textmeasure/textmeasure.go101
LOWlib/geo/point.go221// Creates a Vector pointing to point
LOWlib/geo/point.go241 // they intersect and we compute the point of intersection to return
LOWlib/geo/segment.go61// buffer says how close the segment can be, on both axes, to other segments given
LOWlib/label/label.go561 // Horizontal Edge with Outside Label | Vertical Edge with Outside Label
LOWlib/pptx/pptx.go121 // │ │ │ │ │ IMAGE
LOWd2layouts/d2layouts.go101 gi := NestedGraphInfo(curr)
LOWd2layouts/d2dagrelayout/dagre.js601// * Internally we use an "edgeId", a stringified form of the edgeObj, to
LOWd2layouts/d2grid/layout.go321 gd.height = totalHeight
LOWd2layouts/d2grid/layout.go421 o.Width += growth
LOWd2layouts/d2grid/layout.go461 for _, o := range column {
LOWd2layouts/d2grid/layout.go801 if len(objects) < 2 || nCuts == 0 {
LOWd2layouts/d2grid/layout.go901
LOWd2layouts/d2grid/layout.go921 // . ├─mr──┤ margin.right added to width during layout
LOWd2layouts/d2grid/layout.go941 // . │ widest shape here │
LOWd2layouts/d2grid/layout.go961 // . ├───mr────┤ remove margin we added
LOWd2layouts/d2grid/grid_diagram.go41 }
LOWd2layouts/d2sequence/sequence_diagram.go501 note.ZIndex = NOTE_Z_INDEX
LOWd2layouts/d2sequence/layout_test.go21
LOWd2layouts/d2elklayout/layout.go1061 }
LOWd2layouts/d2elklayout/layout.go1081 // │ │ │ │ ││ │ Height│ │ │ │
LOWd2renderers/d2svg/appendix/appendix.go21 "oss.terrastruct.com/d2/lib/textmeasure"
LOWd2renderers/d2sketch/rough.js1/*eslint-disable */
LOWd2cli/watch.go281 // Benign Chmod.
AI Slop Vocabulary2 hits · 6 pts
SeverityFileLineSnippet
MEDIUMinstall.sh371# flag_parse implements a robust flag parser.
MEDIUMe2etests-cli/main_test.go1721// getNumBoards gets the number of boards in an SVG file through a non-robust pattern search
Slop Phrases2 hits · 6 pts
SeverityFileLineSnippet
MEDIUM…testdata/stable/giant_markdown_test/elk/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
MEDIUM…stdata/stable/giant_markdown_test/dagre/board.exp.json43 "label": "# Markdown: Syntax\n\n- [Overview](#overview)\n - [Philosophy](#philosophy)\n - [Inline HTML](#html)\n
Hyper-Verbose Identifiers4 hits · 5 pts
SeverityFileLineSnippet
LOWd2layouts/d2dagrelayout/dagre.js71 */function injectEdgeLabelProxies(g){_.forEach(g.edges(),function(e){var edge=g.edge(e);if(edge.width&&edge.height){var
LOWd2layouts/d2dagrelayout/dagre.js288scanPos=0,prevLayerLength=prevLayer.length,lastNode=_.last(layer);_.forEach(layer,function(v,i){var w=findOtherInnerSegm
LOWd2layouts/d2dagrelayout/dagre.js315 */function findSmallestWidthAlignment(g,xss){return _.minBy(_.values(xss),function(xs){var max=Number.NEGATIVE_INFINITY
LOWd2renderers/d2latex/polyfills.js11function find(e,t,n){if(void 0===n&&(n=Array.prototype),e&&"function"==typeof n.find)return n.find.call(e,t);for(var r=0