Default resources - Contributing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(WIP)
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
This article contains the <b>official set of rules and guidelines for contributing</b> to the [https://github.com/multitheftauto/mtasa-resources Default resources that come with MTA].
<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 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>
 
<br><br>
 
To be approved
 
<br><br>
 
<h1>Contributing to mtasa-resources</h1>
<p>Welcome to the <strong>mtasa-resources</strong> project! We appreciate your interest in contributing to the development and improvement of the default Lua resources that come with the MTA:SA multiplayer mod. To ensure high-quality code and a smooth collaboration process, please adhere to the following coding guidelines and contributing rules.</p>


<h2>Coding Guidelines</h2>
<h2>Coding Guidelines</h2>
Line 14: Line 5:
<ul>
<ul>
     <li>Write clear, readable, and maintainable code.</li>
     <li>Write clear, readable, and maintainable code.</li>
     <li>Follow the <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY (Don't Repeat Yourself)</a> principle.</li>
     <li>Follow the [https://en.wikipedia.org/wiki/Don%27t_repeat_yourself DRY (Don't Repeat Yourself)] principle.</li>
     <li>Adhere to the <a href="https://en.wikipedia.org/wiki/KISS_principle">KISS (Keep It Simple, Stupid)</a> 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 the purpose.</li>
     <li>Use meaningful variable and function names that convey the purpose.</li>
     <li>Comment your code where necessary to explain the logic.</li>
     <li>Comment your code where necessary to explain the logic.</li>
Line 21: Line 12:


<h3>Indentation and Formatting</h3>
<h3>Indentation and Formatting</h3>
<p>Make sure your code editor is applying the rules established in the project's root <b>.editorconfig</b> file.</p>
<p>Make sure 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>Script Security</h3>
<p>Follow the [[Script security]] principles established for MTA:SA scripts.</p>
 
<h3>Performance Considerations</h3>
<ul>
    <li>Avoid unnecessary computations within loops.</li>
    <li>Cache results of expensive operations when possible.</li>
    <li>Use local variables to improve performance.</li>
</ul>


<h3>Early Return</h3>
<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>
<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>
<pre>
<syntaxhighlight lang="lua">
<code class="lua">
-- Bad example
-- Bad example
function exampleFunction(value)
function exampleFunction(value)
Line 48: Line 48:
     -- Main logic here
     -- Main logic here
end
end
</code>
</syntaxhighlight>
</pre>
 
<h3>Error Handling</h3>
<ul>
    <li>Handle errors gracefully and provide informative error messages.</li>
    <li>Use <code>assert</code> where appropriate to catch critical errors early.</li>
</ul>
 
<h3>Performance Considerations</h3>
<ul>
    <li>Avoid unnecessary computations within loops.</li>
    <li>Cache results of expensive operations when possible.</li>
    <li>Use local variables to improve performance.</li>
</ul>


<h2>Contributing Rules</h2>
<h2>Contributing Rules</h2>
<h3>Submitting Issues</h3>
<h3>Submitting Issues</h3>
<ul>
<ul>
     <li>Check the existing issues before submitting a new one to avoid duplicates.</li>
     <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>Provide a clear and descriptive title and detailed information about the issue.</li>
     <li>Include steps to reproduce the issue, if applicable.</li>
     <li>Include steps to reproduce the issue, if applicable.</li>
Line 84: Line 70:
<h3>Review Process</h3>
<h3>Review Process</h3>
<ul>
<ul>
     <li>All pull requests will be reviewed by project maintainers.</li>
     <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>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>
     <li>Once approved, your pull request will be merged into the main branch.</li>

Latest revision as of 11:44, 29 June 2024

Work in progress - Welcome to the mtasa-resources project! We appreciate your interest in contributing to the development and improvement of the Default Lua resources that come with the Multi Theft Auto multiplayer mod. To ensure high-quality code and a smooth collaboration process, please adhere to the following coding guidelines and contributing rules.

Coding Guidelines

General Principles

Indentation and Formatting

Make sure your code editor (e.g. Visual Studio Code) applies the rules established by the project's .editorconfig file.

Script Security

Follow the Script security principles established for MTA:SA scripts.

Performance Considerations

  • Avoid unnecessary computations within loops.
  • Cache results of expensive operations when possible.
  • Use local variables to improve performance.

Early Return

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.

-- 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

Contributing Rules

Submitting Issues

  • Check the existing issues before submitting a new one to avoid duplicates.
  • Provide a clear and descriptive title and detailed information about the issue.
  • Include steps to reproduce the issue, if applicable.

Submitting Pull Requests

  • Fork the repository and create a new branch for your feature or bugfix.
  • Ensure your code follows the coding guidelines outlined above.
  • Include a clear and descriptive title and description of your changes.
  • Reference any related issues in your pull request description.
  • Ensure your code does not introduce new issues or break existing functionality.
  • Be responsive to feedback and make necessary changes requested during the review process.

Review Process

  • All pull requests will be reviewed by project maintainers.
  • Feedback and requests for changes will be provided through the pull request comments.
  • Once approved, your pull request will be merged into the main branch.