Skip to content

Commit

Permalink
🎨 EOF/trailing whitespace/TOML&YAML check
Browse files Browse the repository at this point in the history
And armed and documented pre-commit
  • Loading branch information
foosel committed Oct 7, 2020
1 parent fbfb34d commit cae6730
Show file tree
Hide file tree
Showing 38 changed files with 85 additions and 54 deletions.
9 changes: 9 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# refs to ignore during git blame, use with --ignore-revs-file

# Change dict constructors to literals
#af60fd642832736966104ae71d852d745397c749

# Change set constructors to literals
#986312b6ae7eeadcaf620cc99d53b23794be83b6

# Switch to black formatting
1f93b2355a2816918e11a55e61b42010d15a6720
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ or request features within OctoPrint (not OctoPi, not any OctoPrint
plugins and not unofficial OctoPrint versions).
Do not seek support here ("I need help with ...", "I have a
question ..."), that belongs on the community forum at
question ..."), that belongs on the community forum at
community.octoprint.org, NOT here.
Mark requests with a "[Request]" prefix in the title please. For bug
Expand All @@ -37,7 +37,7 @@ Thank you!

#### What were you doing?

<!--
<!--
Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
don't know what you did to get it to happen in the first place.
Expand All @@ -61,7 +61,7 @@ to also include a link to a file with which to reproduce the problem.

#### Did the same happen when running OctoPrint in safe mode?

<!--
<!--
Test if you can reproduce your problem in safe mode. You can find information
on how to enable safe mode in the Contribution Guidelines.
Expand Down
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ checklist:
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
new feature, or maintenance if it's a bug fix or improvement of
existing functionality for the current stable version (no PRs
existing functionality for the current stable version (no PRs
against master or anything else please)
* [ ] Your PR was opened from a custom branch on your repository
(no PRs from your version of master, maintenance or devel please),
e.g. dev/my_new_feature or fix/my_bugfix
* [ ] Your PR only contains relevant changes: no unrelated files,
no dead code, ideally only one commit - rebase and squash your PR
no dead code, ideally only one commit - rebase and squash your PR
if necessary!
* [ ] Your changes follow the existing coding style
* [ ] If your changes include style sheets: You have modified the
Expand All @@ -37,7 +37,7 @@ checklist:
* [ ] You have added yourself to the AUTHORS.md file :)

<!--
Describe your PR further using the template provided below. The more
Describe your PR further using the template provided below. The more
details the better!
-->

Expand Down
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|docs/|scripts/|translations/|.*\.css|.*\.svg)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: check-toml
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
args: ['--config', 'black.toml']
language_version: python3.7
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.5.4
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
hooks:
- id: flake8
1 change: 0 additions & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ host = https://www.transifex.com
file_filter = translations/<lang>/LC_MESSAGES/messages.po
source_file = translations/messages.pot
source_lang = en

19 changes: 12 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ and branching strategy.
commits of your full virtual environment). Make sure your PR consists
**ideally of only one commit** (use git's rebase and squash functionality).
7. Make sure you **follow the current coding style**. This means:
* Tabs instead of spaces in the Python files[2]
* Spaces instead of tabs in the JavaScript sources
* Spaces for indenting and alignment, indentation width 4.
* English language (code, variables, comments, ...)
* Comments where necessary: Tell *why* the code does something like it does
it, structure your code
Expand All @@ -347,6 +346,16 @@ and branching strategy.
in the OctoPrint checkout folder. An [automatic build workflow](https://github.com/OctoPrint/OctoPrint/actions?query=workflow%3ABuild)
is also setup so that if the tests should fail, your PR will be marked
accordingly.
9. Run the **pre-commit check suite** against your changes. You can run that (after
[initial development environment setup with "develop" dependencies](https://docs.octoprint.org/en/master/development/environment.html))
by running

```
pre-commit run --all-files
```

in the OctoPrint checkout folder. If you install the pre-commit hooks via
`pre-commit install` this will even be taken care of for you prior to committing.
9. **Test your changes thoroughly**. That also means testing with usage
scenarios you don't normally use, e.g. if you only use access control, test
without and vice versa. If you only test with your printer, test with the
Expand Down Expand Up @@ -415,14 +424,10 @@ See [the corresponding chapter in the documentation](https://docs.octoprint.org/
new features, suggest getting in touch on the forum for larger changes
* 2020-08-10: Update versioning scheme and PR instructions
* 2020-09-23: Move branch & versioning into development docs
* 2020-10-07: Introduce `pre-commit`

## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
to your PR's branch will also become part of your PR, so if you create a
PR from your version of `devel` chances are high you'll add changes to the
PR that do not belong to the PR.
* [2] - Yes, we know that this goes against PEP-8. OctoPrint started out as
a fork of Cura and hence stuck to the coding style found therein. Changing
it now would make the history and especially `git blame` completely
unusable, so for now we'll have to deal with it (this decision might be
revisited in the future).
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Always update to the latest version of OctoPrint to keep up with security patche

## Reporting a Vulnerability

Email to security@octoprint.org.
Email to security@octoprint.org.

For the sake of the userbase of OctoPrint please always disclose responsibly and with a 90+ day window.
2 changes: 1 addition & 1 deletion SUPPORTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ thanks to everyone who contributed!
* Sven Mueller
* Ulrich Kempken

and 1943 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
and 1943 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
14 changes: 12 additions & 2 deletions docs/development/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ below.
binaries cannot be found on your ``PATH`` like this you'll need to specify the full paths to them here,
e.g. ``virtualenv --python=/path/to/python2/bin/python venv2``

* Activate one of the virtual environments:
* Activate one of the virtual environments (the Python 3 venv should be considered the
primary one at this point):

* PY2: ``source venv2/bin/activate`` (Linux, macOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below)
* PY3: ``source venv3/bin/activate`` (Linux, macOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below)
* PY2: ``source venv2/bin/activate`` (Linux, macOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below)

* Update ``pip`` in the virtual environment:

Expand All @@ -49,10 +50,16 @@ below.

* ``pip install -e '.[develop,plugins]'``

* Set up the pre-commit hooks that make sure any changes you do adhere to the styling rules:

* ``pre-commit install``

When the virtual environment is activated you can then:

* run the OctoPrint server via ``octoprint serve``
* run the test suite from the checked out source folder via ``pytest``
* trigger the pre-commit check suite manually from the checked out source folder via
``pre-commit run --all-files``

To switch the activated virtual environment, simply activate the new environment as described above.

Expand Down Expand Up @@ -106,6 +113,7 @@ Then:
source ./venv3/bin/activate
pip install --upgrade pip
pip install -e .[develop,plugins,docs]
pre-commit install
You can then start OctoPrint via ``octoprint`` after activating one of the two virtual environments.

Expand Down Expand Up @@ -149,6 +157,7 @@ Open the Git Bash you just installed and in that:
source ./venv3/Scripts/activate
pip install --upgrade pip
pip install -e .[develop,plugins,docs]
pre-commit install
.. _sec-development-environment-mac:

Expand Down Expand Up @@ -198,6 +207,7 @@ You'll need a user account with administrator privileges.
source venv/bin/activate
pip install --upgrade pip
pip install -e .[develop,plugins]
pre-commit install
.. _sec-development-environment-ides:

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ known_first_party =
octoprint
octoprint_setuptools
octoprint_client

1 change: 0 additions & 1 deletion src/octoprint/plugins/appkeys/templates/appkeys.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
</serviceList>
<presentationURL>{{ presentationUrl }}</presentationURL>
</device>
</root>
</root>
10 changes: 5 additions & 5 deletions src/octoprint/plugins/gcodeviewer/static/js/viewer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ GCODE.renderer = (function(){
viewportChanged = false;
}
}

var reRender = function(){
if (!model) return;

Expand Down Expand Up @@ -587,7 +587,7 @@ GCODE.renderer = (function(){
// alpha value (100% if current layer is being rendered, 30% otherwise)
// Note - If showing currently layer as preview - also render it at 30% and draw the progress over the top at 100%
var alpha = (renderOptions['showNextLayer'] || renderOptions['showCurrentLayer'] || renderOptions['showPreviousLayer']) && isNotCurrentLayer ? 0.3 : 1.0;

var colorLine = {};
var colorMove = {};
var colorRetract = {};
Expand Down Expand Up @@ -726,7 +726,7 @@ GCODE.renderer = (function(){
prevX = x;
prevY = y;
}

if (prevPathType != "fill") {
ctx.stroke();
}
Expand Down Expand Up @@ -863,7 +863,7 @@ GCODE.renderer = (function(){
ctx.translate(translationX, -translationY);

ctx.scale(viewportRatio, viewportRatio);

offsetModelX = 0;
offsetModelY = 0;
offsetBedX = 0;
Expand Down Expand Up @@ -904,7 +904,7 @@ GCODE.renderer = (function(){
},
render: function(layerNum, fromProgress, toProgress){
if (!initialized) this.init();

layerNumStore = layerNum;
progressStore.from = fromProgress;
progressStore.to = toProgress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
return OctoPrintPiSupportClient;
});

Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
For a copy of the GNU General Public License, see
<a href="https://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank" rel="noreferrer noopener">www.gnu.org/licenses/gpl-3.0.en.html</a>.
</p>

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@
</div>
</div>
</form>


Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,3 @@
<button class="btn btn-primary" data-bind="click: savePluginSettings" aria-hidden="true">{{ _('Save') }}</button>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ td.settings_plugin_softwareupdate_column_information {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,3 @@
<button class="btn" data-dismiss="modal" data-bind="enable: !$root.working()" aria-hidden="true">{{ _('Close') }}</button>
</div>
</div>

1 change: 0 additions & 1 deletion src/octoprint/static/js/app/bindings/copywidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ ko.bindingHandlers.copyWidth = {
});
}
};

1 change: 0 additions & 1 deletion src/octoprint/static/js/app/bindings/toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ ko.bindingHandlers.toggle = {
ko.utils.toggleDomNodeCssClass(element, 'active', ko.utils.unwrapObservable(valueAccessor()));
}
};

2 changes: 1 addition & 1 deletion src/octoprint/static/js/app/bindings/valuewithinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ko.bindingHandlers.valueWithInit = {
ko.bindingHandlers.value.init(element, valueAccessor, allBindingsAccessor, context);
},
update: ko.bindingHandlers.value.update
};
};
2 changes: 1 addition & 1 deletion src/octoprint/static/js/app/viewmodels/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ $(function() {

self.clearAllLogs = function() {
self.log([]);
self.plainLogLines([]);
self.plainLogLines([]);
};
// command matching regex
// (Example output for inputs G0, G1, G28.1, M117 test)
Expand Down
2 changes: 1 addition & 1 deletion src/octoprint/static/less/bootstrap/close.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ button.close {
background: transparent;
border: 0;
-webkit-appearance: none;
}
}
2 changes: 1 addition & 1 deletion src/octoprint/static/less/bootstrap/code.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ pre {
.pre-scrollable {
max-height: 340px;
overflow-y: scroll;
}
}
2 changes: 1 addition & 1 deletion src/octoprint/static/less/bootstrap/layouts.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
padding-right: @gridGutterWidth;
padding-left: @gridGutterWidth;
.clearfix();
}
}
2 changes: 1 addition & 1 deletion src/octoprint/static/less/bootstrap/pager.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
color: @grayLight;
background-color: #fff;
cursor: default;
}
}
4 changes: 2 additions & 2 deletions src/octoprint/static/less/bootstrap/responsive-navbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
.border-radius(0);
.box-shadow(none);
}
.nav-collapse .open > .dropdown-menu {
display: block;
.nav-collapse .open > .dropdown-menu {
display: block;
}

.nav-collapse .dropdown-menu:before,
Expand Down
2 changes: 1 addition & 1 deletion src/octoprint/static/less/mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
background-repeat: repeat-x;
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down
}
}
}
2 changes: 1 addition & 1 deletion src/octoprint/templates/i18n.js.jinja2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
window.BABEL_TO_LOAD_{{ catalog.locale }} = {{ catalog | tojson | safe }};
window.BABEL_TO_LOAD_{{ catalog.locale }} = {{ catalog | tojson | safe }};
1 change: 0 additions & 1 deletion src/octoprint/templates/tabs/temperature.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@
</td>
</script>
</div>

1 change: 0 additions & 1 deletion src/octoprint/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9252,4 +9252,3 @@ msgstr "Zeitrafferaufnahme rendern"

#~ msgid "Autodetection timeout (further tries)"
#~ msgstr "Autodetectiontimeout (weitere Versuche)"

2 changes: 1 addition & 1 deletion tests/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
}
Loading

0 comments on commit cae6730

Please sign in to comment.