Skip to content

Commit

Permalink
Merge pull request #37 from devuxd/refactorAndFix
Browse files Browse the repository at this point in the history
Refactor and fix
  • Loading branch information
Sahar Mehrpour authored Jun 5, 2020
2 parents e2d59ad + d0392d6 commit 917388d
Show file tree
Hide file tree
Showing 56 changed files with 1,152 additions and 1,082 deletions.
99 changes: 41 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,27 @@ This file is required for FPMax algorithm (for mining design rules) to execute.
There must be a file name `ruleJson.txt` in the project folder in which all rules are stored. `grammar` field is recently added for each rule.
It is mandatory but is generated for newly added rules. Here is an example for this file:

```
```javascript
[
{
"index": 1,
"index": "1",
"title": "All Buttons must have a title",
"description": "IF a JButton is created\nTHEN it should be initialized and have a title upon creating.",
"tags": [
"Labeling"
],
"ruleType": {
"constraint": "FOLDER",
"checkFor": [
"src"
],
"type": "WITHIN"
},
"quantifier": {
"detail": "JButtons",
"command": "src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\"]"
},
"constraint": {
"detail": "JButtons with labels in constructor",
"command": "src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\" and count(src:init/src:expr/src:call/src:argument_list/src:argument)>0]"
}
"checkForFilesFolders": [
"src"
],
"checkForFilesFoldersConstraints": "INCLUDE",
"processFilesFolders": "WITHIN",
// JButtons
"quantifierXPathQuery": ["src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\"]"],
// JButtons with labels in constructor
"constraintXPathQuery": ["src:unit/src:class/src:block//src:decl_stmt/src:decl[src:type/src:name/text()=\"JButton\" and count(src:init/src:expr/src:call/src:argument_list/src:argument)>0]"]
},
{
"index": 6,
"index": "6",
"title": "Communication between artifacts should be indirected through a Command",
"description": "IF an Artifact needs to communicate with another artifact\nTHEN it should create a Command describing the desired action to be performed.\nEach Artifact exists in a separate shard, which may execute in parallel on a separate server. An artifact may communicate with another artifact by creating a Command which describes the action that it wishes the receiving Artifact to perform.",
"tags": [
Expand All @@ -49,52 +43,39 @@ It is mandatory but is generated for newly added rules. Here is an example for t
"Entity",
"Persistence"
],
"ruleType": {
"constraint": "FOLDER",
"checkFor": [
"src/com/crowdcoding/commands", "src/com/crowdcoding/entities"
],
"type": "MIXED"
},
"quantifier": {
"type": "FIND_FROM_TEXT",
"detail": "Calling constructors of all entity objects",
"command1": "//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]/src:name/text()",
"command2": "//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"<TEMP>\"]"
},
"constraint": {
"type": "RETURN_TO_BASE",
"detail": "Calling constructors of allowed entity objects",
"command1": "//src:unit/src:class/src:block/src:function_decl[src:name/text()=\"execute\"]/src:parameter_list/src:parameter/src:decl/src:type/src:name[not(text()=\"String\")]/text()",
"command2": "//src:unit/src:class[src:name/text()=\"<TEMP>\" or (src:super/src:extends/src:name/text()=\"<TEMP>\")]/src:name/text()",
"command3": "//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"<TEMP>\"]"
}
"checkForFilesFolders": [
"src/com/crowdcoding/commands", "src/com/crowdcoding/entities"
],
"checkForFilesFoldersConstraints": "INCLUDE",
"processFilesFolders": "MIXED",
"quantifierQueryType": "FIND_FROM_TEXT",
// Calling constructors of all entity objects
"quantifierXPathQuery": ["//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]/src:name/text()",
"//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"<TEMP>\"]"]
"constraintQueryType": "RETURN_TO_BASE",
// Calling constructors of allowed entity objects",
"constraintXPathQuery": ["//src:unit/src:class/src:block/src:function_decl[src:name/text()=\"execute\"]/src:parameter_list/src:parameter/src:decl/src:type/src:name[not(text()=\"String\")]/text()",
"//src:unit/src:class[src:name/text()=\"<TEMP>\" or (src:super/src:extends/src:name/text()=\"<TEMP>\")]/src:name/text()",
"//src:unit/src:class[src:super/src:extends/src:name/text()=\"Command\"]/src:block/src:class/src:block/descendant-or-self::src:decl_stmt/src:decl[src:init/src:expr/src:call/src:name/text()=\"<TEMP>\"]"]
},
{
"index": 11,
"index": "11",
"title": "@Entity classes must be registered in the CrowdServlet class",
"description": "IF a class is an Entity class or subclass \nTHEN it must be registered in 'CrowdServlet' class by ObjectifyService.\nAll entities needs to be registered with Objectify, so that Objectify knows to persist them. The registration must be done in 'CrowdServlet.java'",
"tags": [
"Entity", "Objectify", "Persistence"
],
"ruleType": {
"constraint": "FOLDER",
"checkFor": [
"src/com/crowdcoding/entities",
"src/com/crowdcoding/servlets"
],
"type": "MIXED"
},
"quantifier": {
"detail": "Entity classes",
"command": "//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]"
},
"constraint": {
"type": "FIND_FROM_TEXT",
"detail": "Registered classes",
"command1": "//src:unit/src:class[src:name/text()=\"CrowdServlet\"]//src:expr_stmt/src:expr/src:call[src:name/src:name/text()=\"ObjectifyService\" and src:name/src:name/text()=\"register\"]/src:argument_list/src:argument/src:expr/src:name/src:name[1]/text()",
"command2": "//src:unit/src:class[src:name/text()=\"<TEMP>\"]"
}
"checkForFilesFolders": [
"src/com/crowdcoding/entities", "src/com/crowdcoding/servlets"
],
"checkForFilesFoldersConstraints": "INCLUDE",
"processFilesFolders": "MIXED",
// Entity classes
"quantifierXPathQuery": ["//src:unit/src:class[(src:annotation/src:name[text()=\"Entity\"] or src:annotation/src:name[text()=\"Subclass\"])]"]
"constraintQueryType": "FIND_FROM_TEXT",
// Registered classes
"constraintXPathQuery": ["//src:unit/src:class[src:name/text()=\"CrowdServlet\"]//src:expr_stmt/src:expr/src:call[src:name/src:name/text()=\"ObjectifyService\" and src:name/src:name/text()=\"register\"]/src:argument_list/src:argument/src:expr/src:name/src:name[1]/text()",
"//src:unit/src:class[src:name/text()=\"<TEMP>\"]"]
}
]
```
Expand All @@ -104,13 +85,15 @@ It is mandatory but is generated for newly added rules. Here is an example for t

There is also another json file named `tagJson.txt`. In this file we store information about tags. Here is an example for this file:

```
```javascript
[
{
"ID": "0",
"tagName": "Labeling",
"detail": "Rules about labeling the items used in the application. The labeling must follows special policies."
},
{
"ID": "1",
"tagName": "Objects",
"detail": "Rules about object created in the application. For each object there might be some constraints and considerations."
}
Expand Down
18 changes: 9 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {connect} from "react-redux";
import WebSocketManager from "./core/webSocketManager";
import {hashChange} from "./actions";

import TableOfContent from "./ui/tableOfContent";
import TableOfContents from "./ui/tableOfContents";
import RuleTable from "./ui/ruleTable";
import NavBar from "./ui/navBar";
import HeaderBar from "./ui/headerBar";
import MinedRulesComponent from "./ui/minedRulesComponent";
import FeatureSelection from "./ui/FeatureSelection";
import MinedRulesComponent from "./ui/MiningRules/minedRulesComponent";
import FeatureSelection from "./ui/MiningRules/featureSelection";

class App extends Component {

Expand Down Expand Up @@ -64,25 +64,25 @@ class App extends Component {
</div>
<div id={"tableOfContent"}
className={
(["index", "tagJsonChanged", "ruleJsonChanged"].indexOf(this.props.hash[0]) === -1 ) ? "main container hidden" : "main container"
(["index", "tagJsonChanged", "ruleJsonChanged"].indexOf(this.props.currentHash[0]) === -1 ) ? "main container hidden" : "main container"
}>
<TableOfContent/>
<TableOfContents/>
</div>
<div id={"ruleResults"}
className={
(["rules", "tag", "codeChanged", "rulesForFile", "violatedRules"].indexOf(this.props.hash[0]) === -1 ) ? "main container hidden" : "main container"
(["rules", "tag", "codeChanged", "rulesForFile", "violatedRules"].indexOf(this.props.currentHash[0]) === -1 ) ? "main container hidden" : "main container"
}>
<RuleTable/>
</div>
<div id={"minedRules"}
className={
(["minedRules"].indexOf(this.props.hash[0]) === -1 ) ? "main container hidden" : "main container"
(["minedRules"].indexOf(this.props.currentHash[0]) === -1 ) ? "main container hidden" : "main container"
}>
<MinedRulesComponent/>
</div>
<div id={"featureSelection"}
className={
(["featureSelection"].indexOf(this.props.hash[0]) === -1 ) ? "main container hidden" : "main container"
(["featureSelection"].indexOf(this.props.currentHash[0]) === -1 ) ? "main container hidden" : "main container"
}>
<FeatureSelection/>
</div>
Expand All @@ -97,7 +97,7 @@ class App extends Component {
// map state to props
function mapStateToProps(state) {
return {
hash: state["hash"]
currentHash: state.currentHash
}
}

Expand Down
Loading

0 comments on commit 917388d

Please sign in to comment.