# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-->
## indentation
Use 4 spaces as an indent:
```lua
--No
if a then
ngx.say("hello")
end
```
```lua
--Yes
if a then
ngx.say("hello")
end
```
You can simplify the operation by changing the tab to 4 spaces in the editor you are using.
## Space
On both sides of the operator, you need to use a space to separate:
```lua
--No
local i=1
local s = "apisix"
```
```lua
--Yes
local i = 1
local s = "apisix"
```
## Blank line
Many developers will add a semicolon at the end of the line:
```lua
--No
if a then
ngx.say("hello");
end;
```
Adding a semicolon will make the Lua code look ugly and unnecessary. Also, don't want to save the number of lines in the code, the latter turns the multi-line code into one line in order to appear "simple". This will not know when the positioning error is in the end of the code:
```lua
--No
if a then ngx.say("hello") end
```
```lua
--Yes
if a then
ngx.say("hello")
end
```
The functions needs to be separated by two blank lines:
```lua
--No
local function foo()
end
local function bar()
end
```
```lua
--Yes
local function foo()
end
local function bar()
end
```
If there are multiple if elseif branches, they need a blank line to separate them:
When the linefeed is aligned, the correspondence between the upper and lower lines should be reflected. For the example above, the parameters of the second line of functions are to the right of the left parenthesis of the first line.
If it is a string stitching alignment, you need to put `..` in the next line: