Default resources - Contributing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Fix link)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<p><strong>Work in Progress</strong> - Welcome to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project! We appreciate your interest in contributing to the development and improvement of the <strong>Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod</strong>. To ensure high-quality code and a smooth collaboration process, please adhere to the following <strong>coding guidelines and contributing rules</strong>.</p>
This page is related to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project. Read more about it here: [[Default resources]]


<h2>Coding Guidelines</h2>
The guide on how to Contribute to the project is available at https://github.com/multitheftauto/mtasa-docs/blob/main/mtasa-resources/CONTRIBUTING.md
<h3>General Principles</h3>
<ul>
    <li>Write clear, readable, and maintainable code.</li>
    <li>Follow the [https://en.wikipedia.org/wiki/Don%27t_repeat_yourself DRY (Don't Repeat Yourself)] principle.</li>
    <li>Adhere to the [https://en.wikipedia.org/wiki/KISS_principle KISS (Keep It Simple, Stupid)] principle.</li>
    <li>Use meaningful variable and function names that convey their purpose.</li>
    <li>Comment your code where necessary to explain the logic.</li>
</ul>
 
<h3>Indentation and Formatting</h3>
<p>Ensure your code editor (e.g. [https://code.visualstudio.com/ Visual Studio Code]) applies the rules established by the project's <b>.editorconfig</b> file.</p>
 
<h3>Consistent Naming Conventions</h3>
TODO
 
<h3>Use of Constants</h3>
TODO
 
<h3>Script Security</h3>
<p>Follow the [[Script security]] principles established for MTA:SA scripts to ensure the safety and integrity of your code.</p>
 
<h3>Error Handling</h3>
TODO
 
<h3>Performance Considerations</h3>
<ul>
    <li>Avoid unnecessary computations within loops.</li>
    <li>Cache results of expensive operations whenever possible.</li>
    <li>Use local variables to improve performance.</li>
</ul>
 
<h3>Early Return</h3>
<p>To improve code readability, prefer using early returns to handle error conditions or special cases at the beginning of functions. This helps to avoid deep nesting and makes the main logic easier to follow.</p>
<syntaxhighlight lang="lua">
-- Bad example
function exampleFunction(value)
    if value > 0 then
        -- Some logic here
        if value < 100 then
            -- More logic here
            if value ~= 50 then
                -- Main logic here
            end
        end
    end
end
 
-- Good example
function exampleFunction(value)
    if value <= 0 then return end
    if value >= 100 then return end
    if value == 50 then return end
   
    -- Main logic here
end
</syntaxhighlight>
 
<h2>Contributing Rules</h2>
<h3>Submitting Issues</h3>
<ul>
    <li>Check the [https://github.com/multitheftauto/mtasa-resources/issues existing issues] before submitting a new one to avoid duplicates.</li>
    <li>Provide a clear and descriptive title and detailed information about the issue.</li>
    <li>Include steps to reproduce the issue, if applicable.</li>
</ul>
 
<h3>Submitting Pull Requests</h3>
<ul>
    <li>Fork the repository and create a new branch for your feature or bug fix.</li>
    <li>Ensure your code follows the coding guidelines outlined above.</li>
    <li>Commit small, atomic changes with clear commit messages.</li>
    <li>Include a clear and descriptive title and description of your changes.</li>
    <li>Reference any related issues in your pull request description.</li>
    <li>Ensure your code does not introduce new issues or break existing functionality.</li>
    <li>Be responsive to feedback and make necessary changes requested during the review process.</li>
</ul>
 
<h3>Review Process</h3>
<ul>
    <li>All [https://github.com/multitheftauto/mtasa-resources/pulls pull requests] will be reviewed by project maintainers.</li>
    <li>Feedback and requests for changes will be provided through the pull request comments.</li>
    <li>Once approved, your pull request will be merged into the main branch.</li>
</ul>


[[Category: Development]]
[[Category: Development]]

Latest revision as of 14:22, 20 July 2024

This page is related to the mtasa-resources project. Read more about it here: Default resources

The guide on how to Contribute to the project is available at https://github.com/multitheftauto/mtasa-docs/blob/main/mtasa-resources/CONTRIBUTING.md