# Can I add my own syntax check rules?

**URL:** https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091
**Category:** Oxygene
**Created:** [August 1, 2018, 12:08pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091 "2018-08-01T12:08:53Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [August 1, 2018, 12:08pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/1 "2018-08-01T12:08:53Z")

</div>

Because I work a lot with SQL server, my code has a lot of SQL Strings embedded.  
To prevent bugs, the variables that are embedded within those strings must be non nullable.  
I’d like to write my own check for this, bus has Oxygene some framework available that allows me to do that?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 1, 2018, 3:00pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/2 "2018-08-01T15:00:01Z")

</div>

I’m not sure if I completely follow. can you give an example? Note that you can use “not nullable” as type prefix to mark parameters and fields as not allowing null, eg:

```oxygene
method foo(aBar: not nullable string);
begin
end;

foo(nil); // compiler error

var x := if a then "foo" else nil;
foo(x); // compiler warning

```

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [August 1, 2018, 3:58pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/3 "2018-08-01T15:58:33Z")

</div>

I know how to do it, with non nullable variables, but I am trying to find my own mistakes where I forgot to use it.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 1, 2018, 6:54pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/4 "2018-08-01T18:54:44Z")

</div>

ok. can you give me an example?

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [August 2, 2018, 7:03am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/5 "2018-08-02T07:03:36Z")

</div>

@ck: sorry, interpolated string scenario.

@mh:  
The code line:  
`var stmt := "select * from table where value = {myValue}"`

In the case that:

- a string starts with Select or Update or Delete or Insert
- and myValue is a nullable type,

I want a warning.

Another code line:  
`var stmt := "delete from table"`

In the case that:

- a string starts with Update or Delete
- and the string does not contain the word where,

I want also a warning.

And I can think of a lot of other rules I can enforce on my own code, that are specific to my code.  
So, not something that you can implement - I have to implement it myself.

The question is: can I implement such rules?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [August 3, 2018, 10:24am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/6 "2018-08-03T10:24:21Z")

</div>

You could use a method aspect to validate a string like that, but you’d have to wrap it in a call:

var stmt := CheckSQL(…);

where CheckSQL would be eliminated by an aspect and checked.

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [August 3, 2018, 10:33am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/7 "2018-08-03T10:33:50Z")

</div>

No possibility for static code analysis?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [August 3, 2018, 10:39am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/8 "2018-08-03T10:39:31Z")

</div>

We don’t have (outside usable) apis yet that allow you to walk the whole source tree.

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [August 3, 2018, 10:47am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/9 "2018-08-03T10:47:21Z")

</div>

Can you give me some example code for a method aspect?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [August 3, 2018, 11:44am UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/10 "2018-08-03T11:44:06Z")

</div>

I have a string obfuscation attribute which will need todays build; I can show it (but you need the new build for it to work).

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [August 3, 2018, 12:33pm UTC](https://talk.remobjects.com/t/can-i-add-my-own-syntax-check-rules/17091/11 "2018-08-03T12:33:08Z")

</div>

see my reply here [Oxfuscator](https://talk.remobjects.com/t/oxfuscator/16474/39)
