{"id":18026805,"url":"https://github.com/yegor256/xcop","last_synced_at":"2025-04-05T22:08:24.939Z","repository":{"id":24360527,"uuid":"101298669","full_name":"yegor256/xcop","owner":"yegor256","description":"Command Line Style Checker of XML Documents: to make sure they are always formatted nicely","archived":false,"fork":false,"pushed_at":"2025-03-27T07:47:04.000Z","size":202,"stargazers_count":28,"open_issues_count":5,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T21:07:11.431Z","etag":null,"topics":["html","ruby","static-analysis","xml","xml-format","xsl","xslt"],"latest_commit_sha":null,"homepage":"https://www.yegor256.com/2017/08/29/xcop.html","language":"Ruby","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-24T13:37:08.000Z","updated_at":"2025-03-27T07:47:07.000Z","dependencies_parsed_at":"2024-12-15T22:15:02.356Z","dependency_job_id":"8f4d363e-255f-4878-9ec8-bea43875769c","html_url":"https://github.com/yegor256/xcop","commit_stats":{"total_commits":85,"total_committers":6,"mean_commits":"14.166666666666666","dds":0.07058823529411762,"last_synced_commit":"82ddbd41e67972f0759c4f3a49c3445f5573fa9e"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fxcop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fxcop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fxcop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fxcop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/xcop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406091,"owners_count":20933803,"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","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":["html","ruby","static-analysis","xml","xml-format","xsl","xslt"],"created_at":"2024-10-30T08:08:07.279Z","updated_at":"2025-04-05T22:08:24.864Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"XCOP logo\" src=\"/logo.svg\" width=\"64px\"/\u003e\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/xcop)](http://www.rultor.com/p/yegor256/xcop)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/xcop/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/xcop/actions/workflows/rake.yml)\n[![PDD status](http://www.0pdd.com/svg?name=yegor256/xcop)](http://www.0pdd.com/p?name=yegor256/xcop)\n[![Gem Version](https://badge.fury.io/rb/xcop.svg)](http://badge.fury.io/rb/xcop)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/xcop/blob/master/LICENSE.txt)\n[![Maintainability](https://api.codeclimate.com/v1/badges/396ec0584e0a84adc723/maintainability)](https://codeclimate.com/github/yegor256/xcop/maintainability)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/xcop.svg)](https://codecov.io/github/yegor256/xcop?branch=master)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/xcop)](https://hitsofcode.com/view/github/yegor256/xcop)\n\nThis command line tool validates your XML files for proper formatting.\nIf they are not formatted correctly, it prints the difference and\nexits with an error. You can use it in two ways: 1) to fail your build\nif any XML-ish files (for example, XML, XSD, XSL, or XHTML) are not formatted correctly,\nand 2) to format them correctly using the `--fix` option.\n\nRead this blog post first:\n[_XCOP—XML Style Checker_](https://www.yegor256.com/2017/08/29/xcop.html).\n\nMake sure you have [Ruby installed](https://www.ruby-lang.org/en/documentation/installation/)\nand then install the tool:\n\n```bash\n$ gem install xcop\n```\n\nRun it locally and read its output:\n\n```bash\n$ xcop --help\n```\n\nTo validate formatting of your XML files just pass their names\nas arguments:\n\n```bash\n$ xcop file1.xml file2.xml\n```\n\nIf your files are not formatted correctly and `xcop` complains, you\ncan ask it to \"beautify\" them using the `--fix` option:\n\n```bash\n$ xcop --fix broken-file.xml\n```\n\nTo fix all files in a directory, you can do the following\n([this won't work](https://askubuntu.com/questions/343727/) if your file names contain spaces):\n\n```bash\n$ xcop --fix $(find . -name '*.xml')\n```\n\n## Defaults\n\nYou can put command line options into a `.xcop` file in the directory\nwhere you start `xcop`. Each option should take a single line in the file.\nThey will all be _added_ to the list of options you specify. For example,\nas suggested in [this blog post](https://www.yegor256.com/2022/07/20/command-line-defaults.html):\n\n```\n--nocolor\n--quiet\n--include=**/*\n--exclude=**/*.xsl\n--exclude=**/*.html\n```\n\nYou can also create `~/.xcop` file (in your personal home directory), which\nwill also be read and _added_ to the command line options.\n\n## How to use in `Rakefile`?\n\nThis is what you need there:\n\n```ruby\nrequire 'xcop/rake_task'\ndesc 'Run XCop on all XML/XSL files in all directories'\nXcop::RakeTask.new(:xcop) do |task|\n  task.quiet = true # FALSE by default\n  task.includes = ['**/*.xml', '**/*.xsl'] # xml|xsd|xhtml|xsl|html by default\n  task.excludes = ['target/**/*'] # empty by default\nend\n```\n\n## How to use as GitHub action?\n\nCreate a new workflow file in your repository under `.github/workflows/xcop.yml`:\n\n```yaml\n---\nname: XCOP\n\"on\":\n  # run on push to master events\n  push:\n    branches:\n      - master\n  # run on pull requests to master\n  pull_request:\n    branches:\n      - master\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - uses: g4s8/xcop-action@master\n```\n\nTo customize the files pattern, use the `files` parameter:\n\n```yaml\n- uses: g4s8/xcop-action@master\n  with:\n    files: \"src/*.xml\"\n```\n\n## How to use in Maven `pom.xml`?\n\nYou can integrate it with the help of\n[maven-antrun-plugin](http://maven.apache.org/plugins/maven-antrun-plugin/):\n\n```xml\n\u003cproject\u003e\n  [...]\n  \u003cbuild\u003e\n    [...]\n    \u003cplugins\u003e\n      [...]\n      \u003cplugin\u003e\n        \u003cartifactId\u003emaven-antrun-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e1.8\u003c/version\u003e\n        \u003cexecutions\u003e\n          \u003cexecution\u003e\n            \u003cphase\u003everify\u003c/phase\u003e\n            \u003cconfiguration\u003e\n              \u003ctarget\u003e\n                \u003capply executable=\"xcop\" failonerror=\"true\"\u003e\n                  \u003cfileset dir=\".\"\u003e\n                    \u003cinclude name=\"**/*.xml\"/\u003e\n                    \u003cinclude name=\"**/*.xsd\"/\u003e\n                    \u003cexclude name=\"target/**/*\"/\u003e\n                    \u003cexclude name=\".idea/**/*\"/\u003e\n                  \u003c/fileset\u003e\n                \u003c/apply\u003e\n              \u003c/target\u003e\n            \u003c/configuration\u003e\n            \u003cgoals\u003e\n              \u003cgoal\u003erun\u003c/goal\u003e\n            \u003c/goals\u003e\n          \u003c/execution\u003e\n        \u003c/executions\u003e\n      \u003c/plugin\u003e\n    \u003c/plugins\u003e\n  \u003c/build\u003e\n\u003c/project\u003e\n```\n\n## How to use in Ant `project.xml`?\n\nSomething like this should work:\n\n```xml\n\u003cproject\u003e\n  [...]\n  \u003ctarget name=\"xcop\"\u003e\n    \u003capply executable=\"xcop\" failonerror=\"true\"\u003e\n      \u003cfileset dir=\".\"\u003e\n        \u003cinclude name=\"**/*.xml\"/\u003e\n        \u003cinclude name=\"**/*.xsd\"/\u003e\n        \u003cexclude name=\"target/**/*\"/\u003e\n        \u003cexclude name=\".idea/**/*\"/\u003e\n      \u003c/fileset\u003e\n    \u003c/apply\u003e\n  \u003c/target\u003e\n\u003c/project\u003e\n```\n\n## How to contribute\n\nRead [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```\n$ bundle update\n$ bundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fxcop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fxcop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fxcop/lists"}