Code Monkey home page Code Monkey logo

my_linter's Introduction

XML Begginer linter

This a ruby based linter for XML files. It provides feedback about syntaxis errors for XML files.

Preview

Linter

How it works

This version of the XML Begginer linter reads the ./test.xml file included in the project. This XML file linter will catch and display the following syntax errors in the console :

  • There is no well formed PROLOG in the first line of the file
  • There is a PROLOG, but it's not well formed (a '?>' closing tag is missing)
  • There is not a root node
  • There is more than one root node
  • There is a malformed node
  • There is an unrecognizable node (asd <w >s)
  • There is no matching tag for a given node ( <order>val</adorder> )
  • There is no closing tag for a multiline node
  • There are no well formed attributes (<order attr='val">)
  • An inline node has empty value (<order></order>)

The base test.xml file the program reads is included in the project in the root directory folder, however you can change its content to suit your testing needs. Here is the base content of the test.xml file:

[The 'asd' attribute is malformed on purpose to showcase linter functionalities]

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to asd="s >Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Examples

  • Case : Root node closing tag missing

    <?xml version="1.0" encoding="UTF-8"?>
    <note>
      <to asd="s" >Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
    • Linter output:

      Linter

  • Case : Node opening tag and closing tag mismatch

      <?xml version="1.0" encoding="UTF-8"?>
      <note>
        <to asd="s" >Tove</to>
        <from>Jani</fromda>
        <heading>Reminder</heading>
        <body>Don't forget me this weekend!</body>
      </note>
    • Linter output:

      Linter

How to run the linter

First of all, you need to have the linter files in your computer. You can get them either cloning this repository, or downloading its contents directly

  • To clone the repo, go on the project's Github page, click on "Clone or download", copy the contents of the text box, and then run git clone "repo" on the command line, where "repo" is the text you just copied.
  • If you want to download it directly instead, go on the project's Github page, click on "Clone or download", and then on "Download ZIP". After this you need to extract the contents of the zip file on your computer.

Once you have the files on your computer, go on the command line and navigate to the game directory. Once there :

  • Change the content of the test.xml file to suit your testing needs
  • Run the linter directly from the executable file, using the command ./bin/main.rb
  • Pass the main.rb file to the ruby interpreter, using the command ruby bin/main.rb

Requirements

  • Ruby > 2.5
  • Colorize
  • Rubocop

Built With

  • Ruby

Author

๐Ÿ‘ค Diego Antonio Reyes Coronado

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a โญ๏ธ if you like this project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.