Skip to content

Comments

repair pattern#69

Merged
compaluca merged 20 commits intomainfrom
repair-pattern
Aug 22, 2023
Merged

repair pattern#69
compaluca merged 20 commits intomainfrom
repair-pattern

Conversation

@felix-20
Copy link
Contributor

@felix-20 felix-20 commented Jul 4, 2023

This PR should introduce a new feature for the framework, that can help you reviewing your patterns in your library.
Simple usage example:

tpframework patternrepair -l php -p 1 --skip-readme

This command will take a look at PHP pattern 1 and tries to repair it, --skip-readme tells the tool to skip generating a new README file for that pattern.
Repair a pattern means:

  • make sure, a pattern JSON file exists
  • ensure all relative links are correct
  • collect all instances within the pattern path (an instance is identified by a directory, that contains a JSON file in the instance format)
  • make sure the pattern name is correct (therefor the pattern name is derived from the directory name)
  • check the description field and warn if there is no description
  • check the given tags
  • validates the pattern json against the pattern json scheme
  • for each instance, repairing means:
    • ensuring a instance JSON file with the required keys is available
    • ensures all relative links exist
    • check the scala rule if exists and iff necessary adjust the variable names
    • check the description and again warn if there is no description provided
    • checks that the field expectation:expectation is the opposite of properties:negative_test_case
    • validates the instance json against the instance json scheme
    • for PHP patterns:
      • generates new opcode for each php file
      • changes source line and sink line in the pattern JSON

At the moment this feature is only supported for PHP patterns, the feature was developed as part of reviewing all PHP patterns.
This PR aims to change the role of the Pattern and Instance class in the framework a little bit. It enables the possibility, to consider the pattern and the instance without handling the filesystem paths. i.e. the Instance object saves all the paths from the instance JSON as relative paths to a base path. This should make it possible to simplify some of the file system operations.

I would suggest merging this PR after the CPG only feature, as I expect a few merge conflicts

@felix-20 felix-20 requested a review from compaluca July 4, 2023 12:53
@compaluca compaluca merged commit 1b7fd9a into main Aug 22, 2023
@compaluca compaluca deleted the repair-pattern branch August 22, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants