{"id":14008050,"url":"https://github.com/VKCOM/nocolor","last_synced_at":"2025-07-24T03:31:45.401Z","repository":{"id":47631148,"uuid":"380691735","full_name":"VKCOM/nocolor","owner":"VKCOM","description":"Validate the architecture of your PHP project based on the concept of function colors","archived":true,"fork":false,"pushed_at":"2021-08-20T16:32:20.000Z","size":790,"stargazers_count":162,"open_issues_count":5,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-17T17:41:35.710Z","etag":null,"topics":["architecture","kphp","php"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VKCOM.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-27T08:45:24.000Z","updated_at":"2025-01-04T11:14:21.000Z","dependencies_parsed_at":"2022-09-26T19:40:16.962Z","dependency_job_id":null,"html_url":"https://github.com/VKCOM/nocolor","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/VKCOM/nocolor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fnocolor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fnocolor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fnocolor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fnocolor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VKCOM","download_url":"https://codeload.github.com/VKCOM/nocolor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fnocolor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266789209,"owners_count":23984248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["architecture","kphp","php"],"created_at":"2024-08-10T11:01:11.186Z","updated_at":"2025-07-24T03:31:45.035Z","avatar_url":"https://github.com/VKCOM.png","language":"Go","readme":"\u003cimg width=\"350\" alt=\"image\" src=\"https://user-images.githubusercontent.com/51853996/122410502-a543ff00-cf8c-11eb-9b23-6b0c6e900f1e.png\"\u003e\n\n[![](https://github.com/vkcom/nocolor/workflows/Go/badge.svg)](https://github.com/vkcom/nocolor/workflows/Go/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/VKCOM/nocolor)](https://goreportcard.com/report/github.com/vkcom/nocolor) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\n\n\n# NoColor — validate the architecture of your PHP project\n\nNoColor is an **architecture validation tool** based on the [*concept of colored functions*](/docs/introducing_colors.md). This concept was originally invented for [KPHP](https://github.com/VKCOM/kphp) and later exposed as a separate tool to be used in regular PHP projects.\n\nNoColor and [Deptrac](https://github.com/qossmic/deptrac) have similar goals: they both search for bad architectural patterns. But NoColor uses an absolutely different scenario: function coloring. Unlike Deptrac, NoColor analyzes **call chains of any depth** and supports type inferring. Continue reading [NoColor vs Deptrac](/docs/comparison_with_deptrac.md).\n\nNoColor performs **static code analysis**, it has no runtime overhead. It supports type inferring to handle instance method calls, but dynamic invocations like `A::$method()` can't be statically analyzed.\n\nNoColor is built on top of [NoVerify](https://github.com/VKCOM/noverify) and **written in Go**.\n\nOptionally, install an experimental [plugin](https://github.com/i582/nocolor-phpstorm) for **PhpStorm** that brings some handy features.\n\nTheoretically, the same concept can be implemented for almost every language. NoColor targets PHP.\n\n\n## A brief intro to colors\n\nUsing the `@color` PHPDoc tag, you assign **colors** to a function. When a function calls another one, their colors combine to a chain:\n```php\n/** @color green */\nfunction f1() { f2(); }\n\n// this function has no color (it's transparent)\nfunction f2() { f3(); }\n\n/** @color red */\nfunction f3() { /* ... */ }\n```\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"/docs/img/f1-f2-f3-g-t-r.png\" alt=\"f1 f2 f3 colored\" height=\"75\"\u003e\n\u003c/p\u003e\n\nIn **the palette**, you define rules of colors mixing, as this error rule:\n```yaml\ngreen red: calling red from green is prohibited\n```\n\nAll possible call chains are pattern-matched against rules. Hence, `f1 -\u003e f2 -\u003e f3` will trigger the error above.\n\nA color is anything you want: `@color api`, or `@color model`, or `@color controller`. With the palette, you define arbitrary patterns and exceptions. You can mark classes and use namespaces. You can express modularity and even simulate the `internal` keyword.\n\n[Continue reading about colors here](/docs/introducing_colors.md)\n\n\n## Getting started\n\nThe [Getting started](/docs/getting_started.md) page contains a step-by-step guide and copy-paste examples.\n\n\n## The palette.yaml file\n\nOnce you call\n```bash\nnocolor init\n```\nat the root of your project, it creates an example `palette.yaml` file. It contains rules of color mixtures: \n\n```yaml\nfirst group title:\n- rule1 color pattern: rule1 error or nothing\n- rule2 color pattern: rule2 error or nothing\n# other rules in this group\n\n# optionally, there may be many groups\n```\n\nConsider the [Configuration](/docs/configuration.md#format-of-the-paletteyaml-file) page section.\n\n\n## Running NoColor\n\nAt first, [**install**](/docs/install.md) NoColor to your system. The easiest way is just to download a ready binary.\n\nThen, execute this command **once** at the root of your project:\n```bash\nnocolor init\n```\nIt will create a `palette.yaml` file with some examples.\n\nEvery time you need to **check a project**, run\n```bash\nnocolor check\n```\nto perform checking in the current directory, or\n```bash\nnocolor check ./src\n```\nto perform checks in another folder (or many).\n\nTo exclude some paths from analyzing, or to include the `./vendor` dir, consider all possible [command-line options](/docs/configuration.md).\n\n\n## Limitations and speed\n\nAs for now, NoColor supports PHP 7.4 language level. It depends on a Go package [php-parser](https://github.com/z7zmey/php-parser) which is currently frozen. This restriction can be overcome in the future.\n\nNoColor scales easily to the capacities provided. Depending on the number of cores and the speed of a hard disk, NoColor can process up to 300k lines per second.\n\nThe number of groups, colors, and selectors is unlimited, though the more functions are colored — the slower NoColor would work, as the number of colored graph paths **exponentially increases**. Typically, 99% of classes/functions are supposed to be left transparent.   \n\nAll available call chains are calculated **on a static analysis phase**, there is no runtime overhead. NoColor uses some tricky internal optimizations to avoid useless depth searching in a call graph. Every possible colored call chain is matched against all rules in the palette.\n\nRemember, that **PHP is an interpreted language** and allows constructions that can't be statically analyzed. If you write something like `SomeClass::$any_function()` or `new $class_name`, NoColor can't do anything about it.\n\n\n## Contributing\n\nFeel free to contribute to this project. See [CONTRIBUTING.md](/CONTRIBUTING.md) for more information.\n\n\n## The License\n\nNoColor is distributed under the MIT License, on behalf of VK.com (V Kontakte LLC).\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVKCOM%2Fnocolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVKCOM%2Fnocolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVKCOM%2Fnocolor/lists"}