Skip to content

Astropilot/jane_c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jane for C

Jane is an ETNA standards fault detection program for projects written in C. It was written in Python 2.7 for Windows and bases its code analysis on the srcml framework.

This program will check each of the standards defined by ETNA and indicate the problems found with as much precision as possible. You can find the official ETNA Coding Style in pdf format here.

Be aware that this program is developed by a student and that the verifications are based on the "C Coding Style" and may differ from the official verification program used by ETNA.

You are invited to participate in the implementation and correction of the verification rules! For that look at the category "Contributing".

How to use it

Prerequisites

In order to make Jane work, you will need:

/!\ Do not forget to add srcML in PATH env !

Installation

Just make a copy of the git repository and go to the src folder.

$> git clone https://github.com/Astropilot/jane_c.git
$> cd src/

You can now simply launch the main script with the path to your C project as an argument.

$> python jane_c.py C:\Projects\ExampleProject

Rules implemented

The following is a list of the standards that have been implemented and their implementation details:

Rule Implemented Details
O1 ✔️ Fully Implemented
O2 Can't be implemented
O3 ✔️ Fully Implemented
O4 ✔️ ❗ Just checking snake_case convention
G1 ✔️ Fully Implemented
G2 ✔️ Fully Implemented
G3 Can't be implemented
G4 Not implemented
F1 Not implemented
F2 ✔️ ❗ Just checking snake_case convention
F3 ✔️ Fully Implemented
F4 ✔️ Fully Implemented
F5 ✔️ ❗ Not checking if structures are transmitted as parameters using a pointer
F6 ✔️ Fully Implemented
L1 ✔️ Fully Implemented
L2 ✔️ Fully Implemented
L3 Partially implemented
L4 ✔️ Fully Implemented
L5 ✔️ Fully Implemented
L6 ✔️ Fully Implemented
V1 ✔️ Fully Implemented
V2 Not implemented
V3 ✔️ ❗ Not all pointer can be checked (need fix)
C1 ✔️ Fully Implemented
C2 ✔️ Fully Implemented
A1 Can't be implemented
A2 Can't be implemented
H1 Not implemented
H2 ✔️ Fully Implemented
H3 ✔️ Fully Implemented

Contributing

Each rule is defined in a separate file, which you can find in the c_rules folder. I invite you to look at the existing rules in order to understand how to use the different tools available.

However, a minimal structure is required for your rule to be functional:

# -*- coding: utf-8 -*-

"""
Jane for C Projects
Author: YOUR_NAME (https://github.com/Astropilot/jane_c)

RULE_NAME Rule: RULE_SHORT_DESCRIPTION
"""

from etna_style_utils import *
from srcml import *

class RuleChecker:

    def __init__(self, project):
        self.project = project

    def check_rule(self):
        project = self.project
        # From here, you are free to write your code

The project variable allows you to access the list of files contained in the project given as an argument. You can request only certain files, or exclude some.

files = []
files.extend(project.get_files_from_project(project.FILE_TYPES["ALL"], exclude = False))

Here is a list of the already defined types of files you can use:

project.FILE_TYPES["ALL"] = []
project.FILE_TYPES["C_FILES"] = [".c", ".h"]
project.FILE_TYPES["C_SOURCES"] = [".c"]
project.FILE_TYPES["C_HEADERS"] = [".h"]

But of course you can customize the desired file types:

files = []
files.extend(project.get_files_from_project([".txt", ".ext"]))

Thanks to the srcML framework you can obtain the source code of a file in XML format, which allows you to use XPath for example to move around and quickly check the tags.

About

An ETNA C standard correction program

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published