text:
# Buildifier warnings

Warning categories supported by buildifier's linter:

  * [`attr-applicable_licenses`](#attr-applicable_licenses)
  * [`attr-cfg`](#attr-cfg)
  * [`attr-license`](#attr-license)
  * [`attr-licenses`](#attr-licenses)
  * [`attr-non-empty`](#attr-non-empty)
  * [`attr-output-default`](#attr-output-default)
  * [`attr-package-metadata`](#attr-package-metadata)
  * [`attr-single-file`](#attr-single-file)
  * [`build-args-kwargs`](#build-args-kwargs)
  * [`bzl-visibility`](#bzl-visibility)
  * [`confusing-name`](#confusing-name)
  * [`constant-glob`](#constant-glob)
  * [`ctx-actions`](#ctx-actions)
  * [`ctx-args`](#ctx-args)
  * [`deprecated-function`](#deprecated-function)
  * [`depset-items`](#depset-items)
  * [`depset-iteration`](#depset-iteration)
  * [`depset-union`](#depset-union)
  * [`dict-concatenation`](#dict-concatenation)
  * [`dict-method-named-arg`](#dict-method-named-arg)
  * [`duplicated-name`](#duplicated-name)
  * [`filetype`](#filetype)
  * [`function-docstring`](#function-docstring)
  * [`function-docstring-args`](#function-docstring-args)
  * [`function-docstring-header`](#function-docstring-header)
  * [`function-docstring-return`](#function-docstring-return)
  * [`git-repository`](#git-repository)
  * [`http-archive`](#http-archive)
  * [`integer-division`](#integer-division)
  * [`keyword-positional-params`](#keyword-positional-params)
  * [`list-append`](#list-append)
  * [`load`](#load)
  * [`load-on-top`](#load-on-top)
  * [`module-docstring`](#module-docstring)
  * [`name-conventions`](#name-conventions)
  * [`native-android`](#native-android)
  * [`native-build`](#native-build)
  * [`native-cc`](#native-cc)
  * [`native-java`](#native-java)
  * [`native-package`](#native-package)
  * [`native-proto`](#native-proto)
  * [`native-py`](#native-py)
  * [`no-effect`](#no-effect)
  * [`out-of-order-load`](#out-of-order-load)
  * [`output-group`](#output-group)
  * [`overly-nested-depset`](#overly-nested-depset)
  * [`package-name`](#package-name)
  * [`package-on-top`](#package-on-top)
  * [`positional-args`](#positional-args)
  * [`print`](#print)
  * [`provider-params`](#provider-params)
  * [`redefined-variable`](#redefined-variable)
  * [`repository-name`](#repository-name)
  * [`return-value`](#return-value)
  * [`rule-impl-return`](#rule-impl-return)
  * [`same-origin-load`](#same-origin-load)
  * [`skylark-comment`](#skylark-comment)
  * [`skylark-docstring`](#skylark-docstring)
  * [`string-iteration`](#string-iteration)
  * [`uninitialized`](#uninitialized)
  * [`unnamed-macro`](#unnamed-macro)
  * [`unreachable`](#unreachable)
  * [`unsorted-dict-items`](#unsorted-dict-items)
  * [`unused-variable`](#unused-variable)

### How to disable warnings

All warnings can be disabled / suppressed / ignored by adding a special comment `# buildifier: disable=<category_name>` to
the expression that causes the warning. Historically comments with `buildozer` instead of
`buildifier` are also supported, they are equivalent.

#### Examples

```python
# buildifier: disable=no-effect
"""
A multiline comment as a string literal.

Docstrings don't trigger the warning if they are first statements of a file or a function.
"""

if debug:
    print("Debug information:", foo)  # buildifier: disable=print
```

--------------------------------------------------------------------------------

## Do not use `applicable_licenses` as an attribute name.

  * Category name: `attr-applicable_licenses`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-applicable_licenses`

Using `applicable_licenses` as an attribute name may cause unexpected behavior. Its use may be prohibited in future Bazel releases.

--------------------------------------------------------------------------------

## `cfg = "data"` for attr definitions has no effect

  * Category name: `attr-cfg`
  * Flag in Bazel: [`--incompatible_disallow_data_transition`](https://github.com/bazelbuild/bazel/issues/6153)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-cfg`

The [Configuration](https://docs.bazel.build/versions/master/skylark/rules.html#configurations)
`cfg = "data"` is deprecated and has no effect. Consider removing it.
The [Configuration](https://docs.bazel.build/versions/master/skylark/rules.html#configurations)
`cfg = "host"` is deprecated. Consider replacing it with `cfg = "exec"`.

--------------------------------------------------------------------------------

## `attr.license()` is deprecated and shouldn't be used

  * Category name: `attr-license`
  * Flag in Bazel: `--incompatible_no_attr_license`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-license`

The `attr.license()` method is almost never used and being deprecated.

--------------------------------------------------------------------------------

## Do not use `licenses` as an attribute name.

  * Category name: `attr-licenses`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-licenses`

Using licenses as an attribute name may cause unexpected behavior.

--------------------------------------------------------------------------------

## `non_empty` attribute for attr definitions is deprecated

  * Category name: `attr-non-empty`
  * Flag in Bazel: `--incompatible_disable_deprecated_attr_params`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-non-empty`

The `non_empty` [attribute](https://docs.bazel.build/versions/master/skylark/lib/attr.html)
for attr definitions is deprecated, please use `allow_empty` with an opposite value instead.

--------------------------------------------------------------------------------

## The `default` parameter for `attr.output()`is deprecated

  * Category name: `attr-output-default`
  * Flag in Bazel: [`--incompatible_no_output_attr_default`](https://github.com/bazelbuild/bazel/issues/7950)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-output-default`

The `default` parameter of `attr.output()` is bug-prone, as two targets of the same rule would be
unable to exist in the same package under default behavior. Use Starlark macros to specify defaults
for these attributes instead.

--------------------------------------------------------------------------------

## Do not use `package_metadata` as an attribute name.

  * Category name: `attr-package-metadata`
  * Automatic fix: no
  * Not supported by the latest version of Buildifier
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-package-metadata`

Using `package_metadata` as an attribute name may cause unexpected behavior. Its use may be prohibited in future Bazel releases.

--------------------------------------------------------------------------------

## `single_file` is deprecated

  * Category name: `attr-single-file`
  * Flag in Bazel: `--incompatible_disable_deprecated_attr_params`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=attr-single-file`

The `single_file` [attribute](https://docs.bazel.build/versions/master/skylark/lib/attr.html)
is deprecated, please use `allow_single_file` instead.

--------------------------------------------------------------------------------

## `*args` and `**kwargs` are not allowed in BUILD files

  * Category name: `build-args-kwargs`
  * Flag in Bazel: `--incompatible_no_kwargs_in_build_files`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=build-args-kwargs`

Having `*args` or `**kwargs` makes BUILD files hard to read and manipulate. The list of
arguments should be explicit.

--------------------------------------------------------------------------------

## Module shouldn't be used directly

  * Category name: `bzl-visibility`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=bzl-visibility`

If a directory `foo` contains a subdirectory `internal` or `private`, only files located under `foo`
can access it.

For example, `dir/rules_mockascript/private/foo.bzl` can be loaded from
`dir/rules_mockascript/private/bar.bzl` or `dir/rules_mockascript/sub/public.bzl`,
but not from `dir/other_rule/file.bzl`.

--------------------------------------------------------------------------------

## Never use `l`, `I`, or `O` as names

  * Category name: `confusing-name`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=confusing-name`

The names `l`, `I`, or `O` can be easily confused with `I`, `l`, or `0` correspondingly.

--------------------------------------------------------------------------------

## Glob pattern has no wildcard ('*')

  * Category name: `constant-glob`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=constant-glob`

[Glob function](https://docs.bazel.build/versions/master/be/functions.html#glob)
is used to get a list of files from the depot. The patterns (the first argument)
typically include a wildcard (* character). A pattern without a wildcard is
often useless and sometimes harmful.

To fix the warning, move the string out of the glob:

```diff
- glob(["*.cc", "test.cpp"])
+ glob(["*.cc"]) + ["test.cpp"]
```

**There’s one important difference**: before the change, Bazel would silently
ignore test.cpp if file is missing; after the change, Bazel will throw an error
if file is missing.

If `test.cpp` doesn’t exist, the fix becomes:

```diff
- glob(["*.cc", "test.cpp"])
+ glob(["*.cc"])
```

which improves maintenance and readability.

If no pattern has a wildcard, just remove the glob. It will also improve build
performance (glob can be relatively slow):

```diff
- glob(["test.cpp"])
+ ["test.cpp"]
```

--------------------------------------------------------------------------------

## `ctx.{action_name}` is deprecated

  * Category name: `ctx-actions`
  * Flag in Bazel: [`--incompatible_new_actions_api`](https://github.com/bazelbuild/bazel/issues/5825)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=ctx-actions`

The following [actions](https://docs.bazel.build/versions/master/skylark/lib/actions.html)
are deprecated, please use the new API:

  * [`ctx.new_file`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#new_file) → [`ctx.actions.declare_file`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#declare_file)
  * `ctx.experimental_new_directory` → [`ctx.actions.declare_directory`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#declare_directory)
  * [`ctx.file_action`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#file_action) → [`ctx.actions.write`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#write)
  * [`ctx.action(command = "...")`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#action) → [`ctx.actions.run_shell`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#run_shell)
  * [`ctx.action(executable = "...")`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#action) → [`ctx.actions.run`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#run)
  * [`ctx.empty_action`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#empty_action) → [`ctx.actions.do_nothing`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#do_nothing)
  * [`ctx.template_action`](https://docs.bazel.build/versions/master/skylark/lib/ctx.html#template_action) → [`ctx.actions.expand_template`](https://docs.bazel.build/versions/master/skylark/lib/actions.html#expand_template)

--------------------------------------------------------------------------------

## `ctx.actions.args().add()` for multiple arguments is deprecated

  * Category name: `ctx-args`
  * Flag in Bazel: [`--incompatible_disallow_old_style_args_add`](https://github.com/bazelbuild/bazel/issues/5822)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=ctx-args`

It's deprecated to use the [`add`](https://docs.bazel.build/versions/master/skylark/lib/Args.html#add)
method of `ctx.actions.args()` to add a list (or a depset) of variables. Please use either
[`add_all`](https://docs.bazel.build/versions/master/skylark/lib/Args.html#add_all) or
[`add_joined`](https://docs.bazel.build/versions/master/skylark/lib/Args.html#add_joined),
depending on the desired behavior.

--------------------------------------------------------------------------------

## The function is deprecated

  * Category name: `deprecated-function`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=deprecated-function`

The function defined in another .bzl file has a docstring stating that it's deprecated, i.e. it
contains a `Deprecated:` section. The convention for function docstrings is described by
the [`function-docstring`](#function-docstring) warning.

--------------------------------------------------------------------------------

## Depset's "items" parameter is deprecated

  * Category name: `depset-items`
  * Flag in Bazel: [`--incompatible_disable_depset_items`](https://github.com/bazelbuild/bazel/issues/9017)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=depset-items`

The `items` parameter for [`depset`](https://docs.bazel.build/versions/master/skylark/lib/globals.html#depset)
is deprecated. In it's old form it's either a list of direct elements to be
added (use the `direct` or unnamed first parameter instead) or a depset that
becomes a transitive element of the new depset (use the `transitive` parameter
instead).

--------------------------------------------------------------------------------

## Depset iteration is deprecated

  * Category name: `depset-iteration`
  * Flag in Bazel: [`--incompatible_depset_is_not_iterable`](https://github.com/bazelbuild/bazel/issues/5816)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=depset-iteration`

Depsets are complex structures, iterations over them and lookups require flattening them to
a list which may be a heavy operation. To make it more obvious it's now required to call
the `.to_list()` method on them in order to be able to iterate their items:

```python
deps = depset()
[x.path for x in deps]  # deprecated
[x.path for x in deps.to_list()]  # recommended
```

--------------------------------------------------------------------------------

## Depsets should be joined using the depset constructor

  * Category name: `depset-union`
  * Flag in Bazel: [`--incompatible_depset_union`](https://github.com/bazelbuild/bazel/issues/5817)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=depset-union`

The following ways to merge two depsets are deprecated:

```python
depset1 + depset2
depset1 | depset2
depset1.union(depset2)
```

Please use the [depset](https://docs.bazel.build/versions/master/skylark/lib/depset.html) constructor
instead:

```python
depset(transitive = [depset1, depset2])
```

When fixing this issue, make sure you
[understand depsets](https://docs.bazel.build/versions/master/skylark/depsets.html)
and try to
[reduce the number of calls to depset](https://docs.bazel.build/versions/master/skylark/performance.html#reduce-the-number-of-calls-to-depset).

--------------------------------------------------------------------------------

## Dictionary concatenation is deprecated

  * Category name: `dict-concatenation`
  * Flag in Bazel: [`--incompatible_disallow_dict_plus`](https://github.com/bazelbuild/bazel/issues/6461)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=dict-concatenation`

The `+` operator to concatenate dicts is deprecated. The operator used to create a new dict and
copy the data to it. There are several ways to avoid it, for example, instead of `d = d1 + d2 + d3`
you can use one of the following:

  * Use [Skylib](https://github.com/bazelbuild/bazel-skylib):

```python
load("@bazel_skylib//lib:dicts.bzl", "dicts")

d = dicts.add(d1, d2, d3)
```

  * The same if you don't want to use Skylib:

```python
d = dict(d1.items() + d2.items() + d3.items())
```

  * The same in several steps:

```python
d = dict(d1)  # If you don't want `d1` to be mutated
d.update(d2)
d.update(d3)
```

--------------------------------------------------------------------------------

## Dict methods do not have a named argument `default`

  * Category name: `dict-method-named-arg`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=dict-method-named-arg`

Dict methods `get`, `pop` and `setdefault` do not accept a named argument
called `default`. Due to a bug, Bazel currently accepts that named argument.
It is better to use a positional argument instead:

```diff
- mydict.get(5, default = 0)
+ mydict.get(5, 0)
```

--------------------------------------------------------------------------------

## A rule with name `foo` was already found on line

  * Category name: `duplicated-name`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=duplicated-name`

Each label in Bazel has a unique name, and Bazel doesn’t allow two rules to have
the same name. With macros, this may be accepted by Bazel (if each macro
generates different rules):

```python
my_first_macro(name = "foo")
my_other_macro(name = "foo")
```

Although the build may work, this code can be very confusing. It can confuse
users reading a BUILD file (if they look for the rule “foo”, they may read see
only one of the macros). It will also confuse tools that edit BUILD files.

To fix the issue just change the name attribute of one rule/macro.

--------------------------------------------------------------------------------

## The `FileType` function is deprecated

  * Category name: `filetype`
  * Flag in Bazel: [`--incompatible_disallow_filetype`](https://github.com/bazelbuild/bazel/issues/5831)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=filetype`

The function `FileType` is deprecated. Instead of using it as an argument to the
[`rule` function](https://docs.bazel.build/versions/master/skylark/lib/globals.html#rule)
just use a list of strings.

--------------------------------------------------------------------------------

## Function docstring

  * Category names:
    * `function-docstring`
    * `function-docstring-header`
    * `function-docstring-args`
    * `function-docstring-return`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=function-docstring`, `# buildifier: disable=function-docstring-header`, `# buildifier: disable=function-docstring-args`, `# buildifier: disable=function-docstring-return`

Public functions should have docstrings describing functions and their signatures.
A docstring is a string literal (not a comment) which should be the first statement
of a function (it may follow comment lines). Function docstrings are expected to be
formatted in the following way:

```python
"""One-line summary: must be followed and may be preceded by a blank line.

Optional additional description like this.

If it's a function docstring and the function has more than one argument, the docstring has
to document these parameters as follows:

Args:
  parameter1: description of the first parameter. Each parameter line
    should be indented by one, preferably two, spaces (as here).
  parameter2: description of the second
    parameter that spans two lines. Each additional line should have a
    hanging indentation of at least one, preferably two, additional spaces (as here).
  another_parameter (unused, mutable): a parameter may be followed
    by additional attributes in parentheses

Returns:
  Description of the return value.
  Should be indented by at least one, preferably two spaces (as here)
  Can span multiple lines.

Deprecated:
  Optional, description of why the function is deprecated and what should be used instead.
"""
```

Docstrings are required for all public functions with at least 5 statements. If a docstring exists
it should start with a one-line summary line followed by an empty line. If a docstring is required
or it describes some arguments, it should describe all of them. If a docstring is required and
the function returns a value, it should be described.

--------------------------------------------------------------------------------

## Function `git_repository` is not global anymore

  * Category name: `git-repository`
  * Flag in Bazel: [`--incompatible_remove_native_git_repository`](https://github.com/bazelbuild/bazel/issues/6569)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=git-repository`

Native `git_repository` and `new_git_repository` functions are removed.
Please use the Starlark version instead:

```python
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
```

--------------------------------------------------------------------------------

## Function `http_archive` is not global anymore

  * Category name: `http-archive`
  * Flag in Bazel: [`--incompatible_remove_native_http_archive`](https://github.com/bazelbuild/bazel/issues/6570)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=http-archive`

Native `http_archive` function is removed.
Please use the Starlark version instead:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
```

--------------------------------------------------------------------------------

## The `/` operator for integer division is deprecated

  * Category name: `integer-division`
  * Flag in Bazel: [`--incompatible_disallow_slash_operator`](https://github.com/bazelbuild/bazel/issues/5823)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=integer-division`

The `/` operator is deprecated in favor of `//`, please use the latter for
integer division:

```python
a = b // c
d //= e
```

--------------------------------------------------------------------------------

## Keyword parameter should be positional

  * Category name: `keyword-positional-params`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=keyword-positional-params`

Some parameters for builtin functions in Starlark are keyword for legacy reasons;
their names are not meaningful (e.g. `x`). Making them positional-only will improve
the readability.

--------------------------------------------------------------------------------

## Prefer using `.append()` to adding a single element list

  * Category name: `list-append`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=list-append`

Transforming `x += [expr]` to `x.append(expr)` avoids a list allocation.

--------------------------------------------------------------------------------

## Loaded symbol is unused

  * Category name: `load`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=load`

### Background

[load](https://docs.bazel.build/versions/master/skylark/concepts.html#loading-an-extension)
is used to import definitions in a BUILD file. If the definition is not used in
the file, the load can be safely removed. If a symbol is loaded two times, you
will get a warning on the second occurrence.

### How to fix it

Delete the line. When load is used to import multiple symbols, you can remove
the unused symbols from the list. To fix your BUILD files automatically, try
this command:

```bash
$ buildozer 'fix unusedLoads' path/to/BUILD
```

If you want to keep the load, you can disable the warning by adding a comment
`# @unused`.

--------------------------------------------------------------------------------

## Load statements should be at the top of the file

  * Category name: `load-on-top`
  * Flag in Bazel: [`--incompatible_bzl_disallow_load_after_statement`](https://github.com/bazelbuild/bazel/issues/5815)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=load-on-top`

Load statements should be first statements (with the exception of `WORKSPACE` files),
they can follow only comments and docstrings.

--------------------------------------------------------------------------------

## The file has no module docstring

  * Category name: `module-docstring`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=module-docstring`

`.bzl` files should have docstrings on top of them. A docstring is a string literal
(not a comment) which should be the first statement of the file (it may follow
comment lines). For example:

```python
"""
This module contains build rules for my project.
"""

...
```

--------------------------------------------------------------------------------

## Name conventions

  * Category name: `name-conventions`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=name-conventions`

By convention, all variables should be lower_snake_case, constant should be
UPPER_SNAKE_CASE, and providers should be UpperCamelCase ending with `Info`.

--------------------------------------------------------------------------------

## All Android build rules should be loaded from Starlark

  * Category name: `native-android`
  * Flag in Bazel: [`--incompatible_disable_native_android_rules`](https://github.com/bazelbuild/bazel/issues/8391)
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=native-android`

The Android build rules should be loaded from Starlark.

Update: the plans for disabling native rules
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
at the moment it's not required to load Starlark rules.

--------------------------------------------------------------------------------

## The `native` module shouldn't be used in BUILD files

  * Category name: `native-build`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=native-build`

There's no need in using `native.` in BUILD files, its members are available
as global symbols there.

--------------------------------------------------------------------------------

## All C++ build rules should be loaded from Starlark

  * Category name: `native-cc`
  * Flag in Bazel: [`--incompatible_load_cc_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8743)
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=native-cc`

The CC build rules should be loaded from Starlark.

Update: the plans for disabling native rules
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
at the moment it's not required to load Starlark rules.

--------------------------------------------------------------------------------

## All Java build rules should be loaded from Starlark

  * Category name: `native-java`
  * Flag in Bazel: [`--incompatible_load_java_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8746)
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=native-java`

The Java build rules should be loaded from Starlark.

Update: the plans for disabling native rules
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
at the moment it's not required to load Starlark rules.

--------------------------------------------------------------------------------

## `native.package()` shouldn't be used in .bzl files

  * Category name: `native-package`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=native-package`

It's discouraged and will be disallowed to use `native.package()` in .bzl files.
It can silently modify the semantics of a BUILD file and makes it hard to maintain.

--------------------------------------------------------------------------------

## All Proto build rules and symbols should be loaded from Starlark

  * Category name: `native-proto`
  * Flag in Bazel: [`--incompatible_load_proto_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8922)
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=native-proto`

The Proto build rules should be loaded from Starlark.

Update: the plans for disabling native rules
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
at the moment it's not required to load Starlark rules.

--------------------------------------------------------------------------------

## All Python build rules should be loaded from Starlark

  * Category name: `native-py`
  * Flag in Bazel: [`--incompatible_load_python_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/9006)
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=native-py`

The Python build rules should be loaded from Starlark.

Update: the plans for disabling native rules
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
at the moment it's not required to load Starlark rules.

--------------------------------------------------------------------------------

## Expression result is not used

  * Category name: `no-effect`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=no-effect`

The statement has no effect. Consider removing it or storing its result in a variable.

--------------------------------------------------------------------------------

## Load statements should be ordered by their labels

  * Category name: `out-of-order-load`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=out-of-order-load`

Load statements should be ordered by their first argument - extension file label.
This makes it easier to developers to locate loads of interest and reduces chances
for conflicts when performing large-scale automated refactoring.

When applying automated fixes, it's highly recommended to also use
[`load-on-top`](#load-on-top) fixes, since otherwise the relative order
of a symbol load and its usage can change resulting in runtime error.

--------------------------------------------------------------------------------

## `ctx.attr.dep.output_group` is deprecated

  * Category name: `output-group`
  * Flag in Bazel: [`--incompatible_no_target_output_group`](https://github.com/bazelbuild/bazel/issues/7949)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=output-group`

The `output_group` field of a target is deprecated in favor of the
[`OutputGroupInfo` provider](https://docs.bazel.build/versions/master/skylark/lib/OutputGroupInfo.html).

--------------------------------------------------------------------------------

## The depset is potentially overly nested

  * Category name: `overly-nested-depset`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=overly-nested-depset`

If a depset is iteratively chained in a for loop, e.g. the following pattern is used:

```python
for ...:
    x = depset(..., transitive = [..., x, ...])
```

this can result in an overly nested depset with a long chain of transitive elements. Such patterns
can lead to performance problems, consider refactoring the code to create a flat list of transitive
elements and call the depset constructor just once:

```python
transitive = []

for ...:
    transitive += ...

x = depset(..., transitive = transitive)
```

Or in simple cases you can use list comprehensions instead:

```python
x = depset(..., transitive = [y.deps for y in ...])
```

For more information, read Bazel documentation about
[depsets](https://docs.bazel.build/versions/master/skylark/depsets.html)
and
[reducing the number of calls to depset](https://docs.bazel.build/versions/master/skylark/performance.html#reduce-the-number-of-calls-to-depset).

--------------------------------------------------------------------------------

## Global variable `PACKAGE_NAME` is deprecated

  * Category name: `package-name`
  * Flag in Bazel: [`--incompatible_package_name_is_a_function`](https://github.com/bazelbuild/bazel/issues/5827)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=package-name`

The global variable `PACKAGE_NAME` is deprecated, please use
[`native.package_name()`](https://docs.bazel.build/versions/master/skylark/lib/native.html#package_name)
instead.

--------------------------------------------------------------------------------

## Package declaration should be at the top of the file

  * Category name: `package-on-top`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=package-on-top`

Here is a typical structure of a BUILD file:

  * `load()` statements
  * `package()`
  * calls to rules, macros

Instantiating a rule and setting the package defaults later can be very
confusing, and has been a source of bugs (tools and humans sometimes believe
package applies to everything in a BUILD file). This might become an error in
the future.

### What can be used before package()?

The linter allows the following to be before `package()`:

  * comments
  * `load()`
  * variable declarations
  * `package_group()`
  * `licenses()`

--------------------------------------------------------------------------------

## Keyword arguments should be used over positional arguments

  * Category name: `positional-args`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=positional-args`

All top level calls (except for some built-ins) should use keyword args over
positional arguments. Positional arguments can cause subtle errors if the order
is switched or if an argument is removed. Keyword args also greatly improve
readability.

```diff
- my_macro("foo", "bar")
+ my_macro(name = "foo", env = "bar")
```

The linter allows the following functions to be called with positional arguments:

  * `load()`
  * `vardef()`
  * `export_files()`
  * `licenses()`
  * `print()`

--------------------------------------------------------------------------------

## `print()` is a debug function and shouldn't be submitted

  * Category name: `print`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=print`

Using the `print()` function for warnings is discouraged: they are often spammy and
non actionable, the people who see the warning are usually not the people who can
fix the code to make the warning disappear, and the actual maintainers of the code
may never see the warning.

--------------------------------------------------------------------------------

## Calls to `provider` should specify a list of fields and a documentation

  * Category name: `provider-params`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=provider-params`

Calls to `provider` should specify a documentation string and a list of fields:

```python
ServerAddressInfo = provider(
    "The address of an HTTP server. Fields are host (string) and port (int).",
    fields = ["host", "port"]
)
```

Fields should also be documented when needed:

```python
ServerAddressInfo = provider(
    "The address of an HTTP server.",
    fields = {
        "host": "string, e.g. 'example.com'",
        "port": "int, a TCP port number",
    }
)
```

Note that specifying a list of fields is a breaking change. It is an error if a
call to the provider uses undeclared fields. If you cannot declare the list of
fields, you may explicitly set it to None (and explain why in a comment).

```python
AllInfo = provider("This provider accepts any field.", fields = None)

NoneInfo = provider("This provider cannot have fields.", fields = [])
```

See the [documentation for providers](https://docs.bazel.build/versions/master/skylark/lib/globals.html#provider).

--------------------------------------------------------------------------------

## Variable has already been defined

  * Category name: `redefined-variable`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=redefined-variable`

### Background

In .bzl files, redefining a global variable is already forbidden. This helps
both humans and tools reason about the code. For consistency, we want to bring
this restriction also to BUILD files.

### How to fix it

Rename one of the variables.

Note that the content of lists and dictionaries can still be modified. We will
forbid reassignment, but not every side-effect.

--------------------------------------------------------------------------------

## Global variable `REPOSITORY_NAME` is deprecated

  * Category name: `repository-name`
  * Flag in Bazel: [`--incompatible_package_name_is_a_function`](https://github.com/bazelbuild/bazel/issues/5827)
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=repository-name`

The global variable `REPOSITORY_NAME` is deprecated, please use
[`native.repository_name()`](https://docs.bazel.build/versions/master/skylark/lib/native.html#repository_name)
instead.

--------------------------------------------------------------------------------

## Some but not all execution paths of a function return a value

  * Category name: `return-value`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=return-value`

Some but not all execution paths of a function return a value. Either there's
an explicit empty `return` statement, or an implicit return in the end of a
function. If it is intentional, make it explicit using `return None`. If you
know certain parts of the code cannot be reached, add the statement
`fail("unreachable")` to them.

--------------------------------------------------------------------------------

## Avoid using the legacy provider syntax

  * Category name: `rule-impl-return`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=rule-impl-return`

Returning structs from rule implementation functions is
[deprecated](https://docs.bazel.build/versions/master/skylark/rules.html#migrating-from-legacy-providers),
consider using
[providers](https://docs.bazel.build/versions/master/skylark/rules.html#providers)
or lists of providers instead.

--------------------------------------------------------------------------------

## Same label is used for multiple loads

  * Category name: `same-origin-load`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=same-origin-load`

### Background

[load](https://docs.bazel.build/versions/master/skylark/concepts.html#loading-an-extension)
is used to import definitions in a BUILD file. If the same label is used for loading
symbols more the ones, all such loads can be merged into a single one.

### How to fix it

Merge all loads into a single one. For example,

```python
load(":f.bzl", "s1")
load(":f.bzl", "s2")
```

can be written more compactly as

```python
load(":f.bzl", "s1", "s2")
```

--------------------------------------------------------------------------------

## "Skylark" is an outdated name of the language, please use "starlark" instead

  * Category names:
    * `skylark-comment`
    * `skylark-docstring`
  * Automatic fix: yes
  * [Suppress the warning](#suppress): `# buildifier: disable=skylark-comment`, `# buildifier: disable=skylark-docstring`

The configuration language for Bazel is called "Starlark" now, the name "Skylark" is
outdated and shouldn't be used.

--------------------------------------------------------------------------------

## String iteration is deprecated

  * Category name: `string-iteration`
  * Flag in Bazel: [`--incompatible_string_is_not_iterable`](https://github.com/bazelbuild/bazel/issues/5830)
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=string-iteration`

Iteration over strings often leads to confusion with iteration over a sequence of strings,
therefore strings won't be recognized as sequences of 1-element strings (like in Python).
Use string indexing and `len` instead:

```python
my_string = "hello world"
for i in range(len(my_string)):
    char = my_string[i]
    # do something with char
```

--------------------------------------------------------------------------------

## Variable may not have been initialized

  * Category name: `uninitialized`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=uninitialized`

The local value can be not initialized at the time of execution. It may happen if it's
initialized in one of the if-else clauses but not in all of them, or in a for-loop which
can potentially be empty.

--------------------------------------------------------------------------------

## The macro should have a keyword argument called "name"

  * Category name: `unnamed-macro`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=unnamed-macro`

By convention all macro functions should have a keyword argument called `name`
(even if they don't use it). This is important for tooling and automation.

A macro is a function that calls a rule (either directly or indirectly by calling other
macros).

If this function is a helper function that's not supposed to be used outside of its file,
please make it private (rename it so that the name starts with `_`), this will
prevent loading the function from BUILD files and suppress the warning.

--------------------------------------------------------------------------------

## The statement is unreachable

  * Category name: `unreachable`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=unreachable`

The statement is unreachable because it follows a `return`, `break`, `continue`,
or `fail()` statement.

--------------------------------------------------------------------------------

## Dictionary items should be ordered by their keys

  * Category name: `unsorted-dict-items`
  * Automatic fix: yes
  * [Disabled by default](buildifier/README.md#linter)
  * [Suppress the warning](#suppress): `# buildifier: disable=unsorted-dict-items`

Dictionary items should be sorted lexicographically by their keys. This makes
it easier to find the item of interest and reduces chances of conflicts when
performing large-scale automated refactoring.

The order is affected by `NamePriority` dictionary passed using `-tables` or
`-add_tables` flags.

If you want to preserve the original dictionary items order, you can disable
the warning by adding a comment `# @unsorted-dict-items` to the dictionary
expression or any of its enclosing expressions (binary, if etc). For example,

```python
# @unsorted-dict-items
d = {
    "b": "bvalue",
    "a": "avalue",
}
```

will not be reported as an issue because the assignment operation that uses
the dictionary with unsorted items has a comment disabling this warning.

--------------------------------------------------------------------------------

## Variable is unused

  * Category name: `unused-variable`
  * Automatic fix: no
  * [Suppress the warning](#suppress): `# buildifier: disable=unused-variable`

This happens when a variable or function is set but not used in the file, e.g.

```python
x = [1, 2]
```

The line can often be safely removed.

If you want to keep the variable, you can disable the warning by adding a
comment `# @unused`.

```python
x = [1, 2] # @unused

# @unused
def f(
        x,
        y,  # @unused
):
    pass
```

If an unused variable is used for partially unpacking tuples, just prefix
its name with an underscore to suppress the warning:

```python
x, _y = foo()
for _, (a, _b) in iterable:
    print(a + x)
```

The same applies for function arguments that are not used by design:

```python
def foo(a, _b, *_args):
    return bar(a)
```

If a tuple is unpacked not in a for-loop and all variables are unused,
it'll still trigger a warning, even if all variables are underscored:

```python
_a, _b = pair
_unused = 3
```

repository: bazelbuild/buildtools

gha_language: Go

repo_name: bazelbuild/buildtools


text:
## What Is This?

This is a native Swift tool for accessing the KPCC API.

It was designed to be used with iOS, macOS, watchOS, and tvOS targets. With some work it should also be usable for server-side Swift projects, such as [Vapor](https://vapor.codes/).

## License

This project is licensed under the MIT license.

## Installation

To integrate this framework into your Xcode project, clone (or otherwise download) it onto your development machine and drag the included _KPCCAPIClient.xcodeproj_ file into your project's file navigator in Xcode.

Once you have done so, drag the appropriate framework file from the _Products_ group into the Embedded Binaries section of the targets you wish to build it with. Then make sure to _import_ KPCCAPIClient at the top of any file(s) you wish to use it in.

## Basic Usage

Currently, the KPCC API only supports GET requests, used to retrieve information about the associated resource.

These calls are exposed in this API Client as static methods under the associated model struct (ie, `Program` or `Episode`), each beginning with the word `get` - so, for example, you can type "Program.get" and hit escape to display Xcode's autocompletion popover with methods for retrieving Programs.

A number of examples showing common usage are provided below.

## Model

The model layer exposed by this framework largely mirrors the KPCC server API in order to lessen confusion and make it easier to work with.

For instances of Program, Episode, Article, etc. we highly recommend referring to the server API documentation for further details. The properties for the model layer have been designed to adhere as closely as possible to that provided by the server API.

* [KPCC API v3](https://github.com/SCPR/api-docs/tree/master/KPCC/v3)

## Inline Documentation

Option-clicking any method name will provide 'Quick Help' inline documentation for that method. The same applies to instance properties for model objects such as Program, Episode, etc.

## Debug Level

You can modify the level of verbosity by setting a debug level to one of the following levels: `disabled`, `basic`, or `verbose`.

We recommend setting the debug level to `disabled` (the default) for production code.

```
KPCCAPIClient.shared.debugLevel    = .basic
```

## Retrieving Programs

Retrieve Program objects to get information about KPCC programs.

*Example:* The following method returns an array of both 'On Air' and 'Online Only' type Programs.

```
Program.get { (programs, error) in
    if let programs = programs {
        print(programs)
    }
}
```

*Example:* The following method returns an array of 'Online Only' type Programs.

```
Program.get(programsWithStatuses: [.onlineOnly]) { (programs, error) in
    if let programs = programs {
        print(programs)
    }
}
```

*Example:* The following method returns a Program associated with the '_airtalk_' slug.

```
Program.get(withProgramSlug: "airtalk") { (program, error) in
    if let program = program {
        print(program)
    }
}
```

## Retrieving Episodes

Retrieve Episode objects for individual on-demand episodes of KPCC programs.

*Example:* The following method returns an array _AirTalk_ Episodes.

```
Episode.get(withProgramSlug: "airtalk") { (episodes, error) in
    if let episodes = episodes {
        print(episodes)
    }
}
```

*Example:* The following method returns an array of up to _AirTalk_ Episodes (the first page of results).

```
Episode.get(withProgramSlug: "airtalk", limit: 8, page: 1) { (episodes, error) in
    if let episodes = episodes {
        print(episodes)
    }
}
```

*Example:* The following method an Episode with the ID '_123456_'.

```
Episode.get(withID: 123456) { (episode, error) in
    if let episode = episode {
        print(episode)
    }
}
```

## Retrieving Program Schedules

Retrieve ProgramSchedule objects to get information about what programs are or will be played during within a given span of time.

*Example:* The following method returns a ProgramSchedule starting at Monday of the current week and ending 1 week later.

```
ProgramSchedule.get { (programSchedule, error) in
    if let programSchedule = programSchedule {
        print(programSchedule)
    }
}
```

*Example:* The following method returns a ProgramSchedule starting at the current date and ending in 1 day.

```
ProgramSchedule.get(withStartDate: Date(), length: 86400) { (programSchedule, error) in
    if let programSchedule = programSchedule {
        print(programSchedule)
    }
}
```

## Retrieving Articles

Retrieve Article objects for news articles, blog posts, etc.

*Example:* The following method returns an array of 'Blog' or 'News' type Articles.

```
Article.get(withTypes: [.blogs, .news]) { (articles, error) in
    if let articles = articles {
        print(articles)
    }
}
```

*Example:* The following method returns an array of up to 10 'News' type Articles with the search query '_Steve Jobs_' and matching the tag of '_iphone_'.

```
Article.get(withTypes: [.news], date: nil, startDate: nil, endDate: nil, query: "Steve Jobs", categories: nil, tags: ["iphone"], limit: 20, page: nil) { (articles, error) in
    if let articles = articles {
        print(articles)
    }
}
```

*Example:* The following method returns an Article with a specified ID of '_asdf1234_'.

```
Article.get(withID: "asdf1234") { (article, error) in
    if let article = article {
        print(article)
    }
}
```

## Retrieving Events

Retrieve Event objects for live, in-person KPCC events.

*Example:* The following method returns an array of 'Community Engagement' or 'Town Hall' type Events.

```
Event.get(withTypes: [.communityEnagement, .townHall]) { (events, error) in
    if let events = events {
        print(events)
    }
}
```

*Example:* The following method returns an array of up to 10 Cultural type Events, with a start date starting now and an end date 30 days in the future.

```
Event.get(withTypes: [.cultural], startDate: Date(), endDate: Date().addingTimeInterval(86400 * 30), limit: 10) { (events, error) in
    if let events = events {
        print(events)
    }
}
```

## Retrieving Lists

Retrieve List objects for curated lists of Article, Program, or Episode objects.

*Example:* The following method returns an array of Lists, including those with the supplied context of '_ios_'.

```
List.get(withContext: "ios") { (lists, error) in
    if let lists = lists {
        print(lists)
    }
}
```

*Example:* The following method returns a List with the supplied ID of '_123456_'.

```
List.get(withID: 123456) { (lists, error) in
    if let lists = lists {
        print(lists)
    }
}
```

## Retrieving Members

Retrieve Member object.

*Example:* The following method returns a Member associated with the supplied pledge token '_asdf1234_'.

```
Member.get(withPledgeToken: "asdf1234") { (member, error) in
    if let member = member {
        print(member)
    }
}
```

## Retrieving Settings

Retrieve settings (returned as a Dictionary).

*Example:* The following method returns settings not associated with any context.

```
Settings.get(withContext: nil) { (settings, error) in
    if let settings = settings {
        print(settings)
    }
}
```

license: MIT

repository: SCPR/KPCC-API-Swift

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: SCPR/KPCC-API-Swift


text:
# binance-simple-tracker

As simple as it is, it's not intended to work with all pairs on binance and it hasn't been coded in that way, I just made it for myself to check things at my own way, made on python 3.8.

Put your API Key and API Secret, you can find it here https://www.binance.com/en/my/settings/api-management , and put in on the script, no binaries are provided for download.

You all can rework it in your own way, nothing special as I said.

You can use it for whatever you want have a nice day/night.

What does it do?
This

![image](https://user-images.githubusercontent.com/25936173/118055694-e131e600-b388-11eb-91cd-9189d01a1b85.png)

repository: Jonirulah/binance-simple-tracker

branch_name: refs/heads/main

repo_name: Jonirulah/binance-simple-tracker


text:
# `angular` — the wootric configured project for Angular apps

This project is an application skeleton for a typical [Wootric](https://www.wootric.com/) setup web app. You can use it
to quickly bootstrap your wootric setup angular webapp projects.

The app doesn't do much, just shows how to setup the wootric snippet for Anuglar projects.

## Getting Started

To get you started simply follow the instructions below:

### Prerequisites

You need git to clone the [spa-examples](https://github.com/Wootric/spa-examples) repository. You can get git from [here](https://git-scm.com/).

We also use a number of Node.js tools to install `angular-cli`. You must have Node.js and its package manager (npm) installed. You can get them from [here](https://nodejs.org/). Then install Angular CLI globally with command `npm install -g @angular/cli`

### Clone `spa-examples`

Clone the `spa-examples` repository using git:

```
git clone https://github.com/Wootric/spa-examples.git
cd spa-exaples
cd angular
npm install
````

### Setup Wootric (using angular directive)
1. Check `src/app/wootric.directive.ts` and setup wootric as required: Update `account_token` with your account token (at line no. 14).

2. Using the directive: Add directive `appWootric` to `src/app/app.component.html` (here at line no. 2).

### Running the Application

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`.

*app built using [Angular CLI](https://github.com/angular/angular-cli) version 8.0.4*


text:
# Advanced Codable Helpers
![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)
![Linux](https://img.shields.io/badge/os-linux-green.svg?style=flat)
![Apache 2](https://img.shields.io/badge/license-Apache2-blue.svg?style=flat)
![Swift](https://img.shields.io/badge/Swift->=4.0-green.svg?style=flat)

Helper classes, protocols and functions designed to make more complex encoding/decoding easier.

### Extensions

* **DecoderType**
    * **decode**\<T\>(from: data, decodingFunc: (Decoder) throws -> T) -> T
       * Provides custom decoding of objects from the root decoding object of any object that implements DecoderType
    * **dtDecode**\<T\>(from: data, decodingFunc: (Decoder) throws -> T) -> T
        * Provides custom decoding of objects from the root decoding object of any object that implements DecoderType
    * **decodeAnyDictionary**\<D\>(from data: EncodedData, excludingKeys: [D.Key] = [], customDecoding: @escaping (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> D where D: ReEncapsulatableDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Decode a dictionary with Any as the Value element
    * **decodeAnyArray**(from data: EncodedData, customDecoding: @escaping (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> [Any]
        * Decode an array of Any objects
    * **dynamicElementDecoding**\<Element\>(_ type: Element.Type, from data: EncodedData, usingKey elementKey: String) throws -> Array\<Element\> where Element: Decodable
        * Provides an easy way of decoding dictionaries of objects like an array using the key as one of the object property values.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the DecodingType handles Dictionaries

* **StandardDecoderType**
    * **decode**\<T\>(from: Data, decodingFunc: (Decoder) throws -> T) -> T
       * Provides custom decoding of objects from the root decoding object of any object that implements DecoderType (JSONDecoder, PropertyListDecoder, ...)
    * **stdDecode**\<T\>(from: Data, decodingFunc: (Decoder) throws -> T) -> T
        * Provides custom decoding of objects from the root decoding object of any object that implements DecoderType (JSONDecoder, PropertyListDecoder, ...)
    * **stdDecodeAnyDictionary**\<D\>(from data: Data, excludingKeys: [D.Key] = [], customDecoding: @escaping (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> D where D: ReEncapsulatableDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Decode a dictionary with Any as the Value element
    * **stdDecodeAnyArray**(from data: EncodedData, customDecoding: @escaping (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> [Any]
        * Decode an array of Any objects
    * **stdDynamicElementDecoding**\<Element\>(_ type: Element.Type, from data: EncodedData, usingKey elementKey: String) throws -> Array\<Element\> where Element: Decodable
        * Provides an easy way of decoding dictionaries of objects like an array using the key as one of the object property values.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the DecodingType handles Dictionaries

  * **EncoderType**
    * **encodeAnyDictionary**\<D\>(_ dictionary: D) throws -> EncodedData where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container
    * **encodeAnyArray**\<S\>(_ array: S) throws -> EncodedData where S: Sequence, S.Element == Any
        * Encodes a Sequence of Any objects if supported from the root
    * **dynamicElementEncoding**\<S\>(_ s: S, usingKey elementKey: String) throws -> EncodedData where S: Sequence, S.Element: Encodable
        * Provides an easy way of encoding an array of objects like a dictionary using one of the object properties as the key.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the EncodingType handles Dictionaries
    * **encodeArray**\<S\>(_ array: S) throws -> EncodedData where S: Sequence, S.Element == Any

  * **StandardEncoderType**
    * **stdEncodeAnyDictionary**\<D\>(_ dictionary: D) throws -> EncodedData where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container
    * **stdEncodeAnyArray**\<S\>(_ array: S) throws -> EncodedData where S: Sequence, S.Element == Any
        * Encodes a Sequence of Any objects if supported from the root
    * **dynamicElementEncoding**\<S\>(_ s: S, usingKey elementKey: String) throws -> EncodedData where S: Sequence, S.Element: Encodable
        * Provides an easy way of encoding an array of objects like a dictionary using one of the object properties as the key.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the EncodingType handles Dictionaries
    * **encodeArray**\<S\>(_ array: S) throws -> EncodedData where S: Sequence, S.Element == Any

* **Decoder**
    * **decodeFromSingleOrArray**\<Element\>(customDecoding: (_ decoder: Decoder) throws -> Element) throws -> [Element]
        * Provides an easy method of decoding an optional/single value/array object into an array
    * **dynamicElementDecoding**\<Element\>(usingKey elementKey: String, decodingFunc: (_ decoder: Decoder) throws -> Element) throws -> Array\<Element\>
        * Provides an easy way of decoding dictionaries of objects like an array using the key as one of the object property values.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the DecodingType handles Dictionaries

* **Encoder**
    * **encodeToSingleOrArray**\<C\>(_ collection: C) throws -> SingleOrArrayEncodedAs  where C: Collection, C.Element: Encodable
        * Provides an easy method to encode an array of encodable objects in a dynamic way
    * **dynamicElementEncoding**\<S\>(_ s: S, usingKey elementKey: String) throws where S: Sequence, S.Element: Encodable
        * Provides an easy way of encoding an array of objects like a dictionary using one of the object properties as the key.
        * **Note**: Array order is not guarenteed.  This is dependant on how the the EncodingType handles Dictionaries

* **KeyedDecodingContainerProtocol**
    * **decode**\<T\>(forKey key: Self.Key, decodingFunc: (Decoder) throws -> T) throws -> T
       * Provides custom decoding of an object
    * **decodeArray**\<T\>(forKey key: Self.Key, decodingFunc: (Decoder) throws -> T) throws -> [T]
       * Provides custom decoding of an array of objects
        * Provides custom decoding of an array of objects if present otherwise returns defaultValue
    * **decodeAnyDictionary**\<D\>(forKey key: Key, excludingKeys: [D.Key] = [], customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> D where D: ReEncapsulatableDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Decode a Dictionary type based on return from the given container
    * **decodeAnyArray**(forKey key: Key, customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> Array\<Any\>
        * Decodes an Array\<Any\> from the container
    * **decodeFromSingleOrArray**\<Element\>(forKey key: Key, customDecoding: (_ decoder: Decoder) throws -> Element) throws -> [Element]
        * Provides an easy method of decoding an optional/single value/array object into an array

* **KeyedEncodingContainerProtocol**
    * **encodeAnyDictionary**\<D\>(_ dictionary: D, forKey key: Key) throws where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container where the Value type is Any
    * **encodeAnyDictionaryIfPresent**\<D\>(_ dictionary: D?, forKey key: Key) throws -> Bool where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container where the Value type is Any
        * Returns true if encoding occured, otherwise false
    * **encodeAnyArray**\<S\>(_ array: S, forKey key: Key) throws where S: Sequence, S.Element == Any
        * Encodes an array of Any to an UnkeyedEncodingContainer if possible
    * **encodeAnyArrayIfPresent**\<S\>(_ array: S?, forKey key: Key) throws -> Bool where S: Sequence, S.Element == Any
        * Encodes an array of Any to an UnkeyedEncodingContainer if possible
        * Returns true if encoding occured, otherwise false

* **SingleValueDecodingContainer**
    * **decode**\<T\>(decodingFunc: (Decoder) throws -> T) throws -> T
       * Provides custom decoding of an object
    * **decodeArray**\<T\>(decodingFunc: (Decoder) throws -> T) throws -> [T]
       * Provides custom decoding of an array of objects
    * **decodeAnyDictionary**\<D\>(excludingKeys: [D.Key] = [], customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> D where D: ReEncapsulatableDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Decode a Dictionary type based on return from the given container
    * **decodeAnyArray**(customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> Array\<Any\>
        * Decodes an Array\<Any\> from a Container
    * **decodeFromSingleOrArray**\<Element\>(customDecoding: (_ decoder: Decoder) throws -> Element) throws -> [Element]
        * Provides an easy method of decoding an optional/single value/array object into an array

* **SingleValueEncodingContainer**
    * **encodeAnyDictionary**\<D\>(_ dictionary: D) throws where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container
    * **encodeAnyArray**\<S\>(_ array: S) throws where S: Sequence, S.Element == Any
        * Encodes an array of Any to the container
        * **Note**: All objects within the array must implement the Encodable protocol

* **UnkeyedDecodingContainer**
    * **decode**\<T\>(decodingFunc: (Decoder) throws -> T) throws -> T
       * Provides custom decoding of an object
    * **decodeArray**\<T\>(decodingFunc: (Decoder) throws -> T) throws -> [T]
       * Provides custom decoding of an array of objects
    * **decodeDictionary**\<D\>(excludingKeys: [D.Key] = [], customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> D where D: ReEncapsulatableDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Decode a Dictionary type based on return from the given container
    * **decodeArray**(_ type: [Any].Type, customDecoding: (_ decoder: Decoder) throws -> Any? = { _ in return nil }) throws -> Array\<An\y>
        * Decodes an Array\<Any\> from a Container
    * **decodeFromSingleOrArray**\<Element\>(customDecoding: (_ decoder: Decoder) throws -> Element) throws -> [Element]
        * Provides an easy method of decoding an optional/single value/array object into an array

* **UnkeyedEncodingContainer**
    * **encodeAnyDictionary**\<D\>(_ dictionary: D) throws where D: SDictionary, D.Key: DictionaryKeyCodable, D.Value == Any
        * Encode a dictionary to a container
    * **encodeAnyArray**\<S\>(_ array: S) throws where S: Sequence, S.Element == Any
        * Encodes an array of Any to the container

### Helper Containers

#### Bridged

Allows for bridging between different CodingKeys

* **BridgedKeyedDecodingContainer**
* **BridgedKeyedEncodingContainer**

#### Delayed

Allows the developer to delay the real encoding process until they decide to

* **DelayedEncoder**
* **DelayedKeyedEncodingContainer**
* **DelayedUnkeyedEncodingContainer**
* **DelayedSingleValueEncodingContainer**

#### Filtered

Allows the developer to filter objects out from being writting to the encoder

* **FilteredKeyedEncodingContainer**
* **FilteredUnkeyedEncodingContainer**

#### FilteredDelayed

Is a combination of filtered and delayed.  These are good for moving properties around

* **FilteredDelayedEncoder**
* **FilteredDelayedKeyedEncodingContainer**
* **FilteredDelayedUnkeyedEncodingContainer**
* **FilteredDelayedSingleValueEncodingContainer**

#### Injected

Allows the developer to add in objects to the decoding process

* **InjectedKeyedDecodingContainer**
* **InjectedSingleValueDecodingContainer**
* **InjectedUnkeyedDecodingContainer**
* **WrappedInjectedKeyedDecodingContainer**

### Helper Coders

Used to calling new coder processing withing an already coding process.  They wrap the current container into a coder object for use on the encode(to:) and the init(from:)

* **WrappedKeyedDecoder**
* **WrappedKeyedEncoder**
* **WrappedSingleValueDecoder**
* **WrappedSingleValueEncoder**
* **WrappedUnkeyedDecoder**
* **WrappedUnkeyedEncoder**

#### Custom CodingPath Wrappers

Used to change the outward looking codingPath on objects.  This is helpful when manipulating the coding path on the fly

* **WrappedKeyedDecodingContainer**
* **WrappedUnkeyedDecodingContainer**
* **WrappedKeyedEncodingContainer**
* **WrappedUnkeyedEncodingContainer**
* **WrappedSingleValueDecodingContainer**
* **WrappedSingleValueEncodingContainer**
* **WrappedDecoder**
* **WrappedEncoder**

### Helper Catchers

Catches either the Encoder or Decoder for use outside the normal coding process

* **EncoderCatcher**
* **DecoderCatcher**

### Helpers

* **CodableHelper** - All static functions within this class are now deprecated.  Please refer to the proper container/encoder/decoder for an equivinalt replacement method
    * **sequences** - Where sequence related helper methods are located
        * **dynamicElementEncoding** - Encodes an array like a dictionary based on a property in the object type
            * **Notes**
                * Array order is not guaranteed
                * CodingPath when encoding will be malformed.  The Dynamic Key will be missing
        * **dynamicElementDecoding** - Decodes a dictionary into an array moving the key to a specific property named value
            * **Notes**
                * Array order is not guaranteed
                * CodingPath when decoding will be malformed.  The Dynamic Key will be missing
    * **arrays** - Where array related encode/decode helper methods are located
        * **Notes**
            * When working with numeric values with, if the decimal portion is Zero, the encoder will cut it down to an Int, and the decoder will then read it as an Int
            *  When working with Bools stored in Any, on Linux Swift versions 4.0-4.0.3 when decoding they convert to Int.  This is an issue with the JSONDecoder.  It works correctly in 4.2.
    * **dictionaries** - Where dictionary related encode/decode helper methods are located
       * **Notes**
            * When working with numeric values with, if the decimal portion is Zero, the encoder will cut it down to an Int, and the decoder will then read it as an Int
            * When working with Bools stored in Any, on Linux Swift versions 4.0-4.0.3 when decoding they convert to Int.  This is an issue with the JSONDecoder.  It works correctly in 4.2.

### Protocols

* **CodableSequenceDynamicKeyHelper** - A protocol used on types that implement Sequence that provide the necessary logic to encode into dictionaries based on a specific property name and decode back into an sequence.  This protocol relies on the dynamicElementEncoding and dynamicElementDecoding methods
* **BaseEncoderTypeBoxing** - A protocol for defining the type boxing methods used by the encoders.  Allows for overriding the value being encoding
* **BaseDecoderTypeUnboxing** - A protocol for defining the type unboxing methods used by decoders.  Allows for overriding the value being decoded

## Usage

Object:
```swift
public struct Person {
    let name: String
    let age: Int
}
// Implement Codable on Person
extension Person: Codable {
    ...
}

// Custom Sequence that contains Person objects
public struct PersonSequence: MutableCollection, Codable {
    public typealias Element = Person
    static var ElementKey: String = "name"

    // rest of code to setup this as a MutableCollection
    ...
}
```

Simple Array Coding:
```swift
import CodableHelpers
// Setup array
let array: [Person] = [Person(name: "Person A", age: 36),
                       Person(name: "Person B", age: 30)]

let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
// Encode the array
let d = try encoder.dynamicElementEncoding(ary, usingKey: "name")
let s = String(data: d, encoding: .utf8)!
print(s)

let decoder = JSONDecoder()
// Decode the array
let r = try decoder.dynamicElementDecoding(from: d,
                                           usingKey: "name",
                                           ofType: Person.self)
print(r)
```

Custom Sequence Coding:
```swift
import CodableHelpers
// Setup sequence
let p1 = Person(name: "Person A", age: 36)
let p2 = Person(name: "Person B", age: 30)

var array: PersonSequence = PersonSequence()
array.append(p1)
array.append(p2)

let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
// Encode the sequence
let d = try encoder.encode(ary)
let s = String(data: d, encoding: .utf8)!
print(s)

let decoder = JSONDecoder()
// Decode the sequence
let r = try decoder.decode(PersonSequence.self, from: d)
print(r)
```

## Dependencies

* **[Basic Codable Helpers](https://github.com/TheAngryDarling/SwiftBasicCodableHelpers.git)** - Package that provides basic helper methods on Encoder and Decoder containers
* **[Nillable](https://github.com/TheAngryDarling/SwiftNillable.git)** - Package used to identify nil/NSNull objects when stored in Any format
* **[SwiftClassCollection](https://github.com/TheAngryDarling/SwiftClassCollections.git)** - Package used to work with swift class based collections that are equivalent to Array and Dictionary

## Author

* **Tyler Anger** - *Initial work* - [TheAngryDarling](https://github.com/TheAngryDarling)

## License

This project is licensed under Apache License v2.0 - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

Based on and in some cases copied/modified from [Swift Source Code](https://github.com/apple/swift/blob/master/stdlib/public/core/Codable.swift.gyb) to ensure similar standards when dealing with encoding/decoding.


text:
# Starcounter.Authorization

This library helps implement authorization in Starcounter apps. It is built on top of ASP.NET Core Authorization feature. This readme explains features of this library, but also some basic features of ASP.NET Core Authorization.

## Table of contents

- [Getting started](#getting-started)
- [Securing view-models](#securing-view-models)
- [Available services](#available-services)
  * [IAuthenticationTicketService<UserSession>](#iauthenticationticketservice-usersession)
  * [ICurrentUserProvider<TUser>](#icurrentuserprovider-tuser)
  * [ISignOutService](#isignoutservice)
  * [IAuthorizationEnforcement](#iauthorizationenforcement)
- [What happens when permissions are denied?](#what-happens-when-permissions-are-denied)

Table of contents generated with markdown-toc

## Getting started

1. If your app doesn't use [`Starcounter.Startup`](https://github.com/Starcounter/Starcounter.Startup) already, start using it. It's possible to use `Starcounter.Authorization` without it, but this topic is not covered here
1. Install `Starcounter.Authorization` package in your app
1. Copy classes from the [Example directory](ExampleDataModel/) into your project, remember to change namespace to your own
1. In your `Startup` class, in the `ConfigureServices` method, add the following line:

```c#
services.AddStarcounterAuthorization<AuthorizationSettings, UserSession, TicketToSession, User>()
```

1. If your project won't build because of TODO weaver error, do the following:
  1. Add `<DisallowDatabaseClasses>True</DisallowDatabaseClasses>` to `<PropertyGroup>` section of your app's csproj
  1. Add references to `Starcounter.QueryProcessor` and `Starcounter.BindingInterfaces` to your app's project (References -> Add -> Assemblies -> Extensions)
  1. Add a new project to your solution, move all of your database classes there and reference it from your app's project

If you want, you can now alter the `User` and `UserSession` classes to suit your needs.

## Securing view-models

To prevent unauthorized access to your view-models, annotate them with `[Authorize]`, like so:

```c#
[Authorize]
public partial class DogsViewModel: Json
```

This has two effects:
* A [middleware](https://github.com/Starcounter/Starcounter.Startup#middleware) prevents this view-model from loading if the current user is not signed in
* An [input handler](https://docs.starcounter.io/topic-guides/typed-json/code-behind#handling-input-events) is generated for every property of this view-model, checking if the user is signed in. Existing input handlers are wrapped in this checkers. What happens if the user is not signed in is [configurable](#what-happens-when-permissions-are-denied)

In summary, only signed in users can interact with this view-model.

## Available services

This library registers some services in the DI container.

### IAuthenticationTicketService<UserSession>

The only method of this service intended to be used by general applications is `GetCurrentAuthenticationTicket`. It returns the current authentication ticket as is foreshadowed by its name. The ticket will be available even if the user is not signed in, and it resembles a session in other Web Frameworks.

### ICurrentUserProvider<TUser>

Its sole method returns the current user or `null` if none is signed in.

### ISignOutService

Its sole method signs out the current user by removing the current authentication ticket. The current page should be reloaded afterwards, or some features that expect an authentication ticket might not work properly.

### IAuthorizationEnforcement

Its methods allow checking if the current user meets certain [policies or requirements](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-2.1).

## What happens when permissions are denied?

There are two situations in which an unauthorized action may be prevented by this library. What happens then can be overriden by [configuring](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-2.1#configure-simple-options-with-a-delegate) `SecurityMiddlewareOptions`.

When the user first loads a page which they aren't authorized to access, the view-model is not created. Instead a `404` response is returned. To override this behavior change the `UnauthenticatedResponseCreator` property.

```c#
services.Configure<SecurityMiddlewareOptions>(options => options.WithUnauthenticatedResponseCreator(uri => new DenyPage()));
```

The code above results in `DenyPage` being sent instead of the default `404` response. `uri` parameter in the lambda is the original URI, relative to the application root.

When the user interacts with the view-model in a way that is not permitted by the library, the offending patch is not applied to the view-model and the original input handler is not invoked. Instead an exception is thrown, destroying the Palindrom session. To override this behavior change the `CheckDeniedHandler` property.

```c#
services.Configure<SecurityMiddlewareOptions>(options => options.WithCheckDeniedHandler((type, data, viewModel) => Expression.Throw(Expression.New(typeof(Exception)))));
```

The code above will result in `new Exception()` being thrown on offence. The lambda passed is executed during code generation to determine action to be taken on offence. It uses [Expression Trees API](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/expression-trees/). `type` parameter is the view-model type for which the handler is generated, `data` is the expression to access `Data` property of the view-model and `viewModel` is the expression to access the view-model itself.

gha_language: C#

gha_license_id: MIT


text:
# jquery.jsonp_callback

JSONP with additional arguments passed to the callback

## Intro

When performing a JSONP request we can only specify `http://url.org/file.json?callback=?`which results in a by jQuery created function, returning only the responded json

When performing JSONP calls within a loop we are unable to determ in which order the request will complete and also unable to add additional arguments to the callback.

This small plugin helps you in these cases by giving you the ability to add additional arguments to the callback function.

## Examples

see [http://manuel.manuelles.nl/jquery.jsonp_callback/](http://manuel.manuelles.nl/jquery.jsonp_callback/)


text:
# Freeboard

Freeboard is a stateless, multi-station ready, Openlayers chartplotter for Signal K.

Display and manage routes, waypoints, notes, alarms, notifications on your Signal K server
from multiple clients.

## Features:
---

### Vessel / Chart Display:

Moving map display with the ability to use a combination of online and locally served charts.

Ability to select the active vessel and direct actions to it _(where supported by the server)_.

- North-up / Vessel-up
- Moving Map / Moving Vessel
- Vessel Heading / Bearing lines
- Wind True / Apparent display
- Measure distance

__Online:__

- OpenStreetMap / WORLD chart outline
- OpenSeaMap

__Offline:__

- MBTiles (or compatible) charts hosted on the Signal K server via `/resources/charts` path.

---

### Resources:

#### Routes and Waypoints

- List / Select resources available via `/resources/routes`, `/resources/waypoints` paths
- Set an active Route
- Select destination point along and Active Route
- Select a Waypoint as a destination
- Draw Routes
- Add Waypoint at: Cursor or Vessel position
- Edit and delete Routes / Waypoints
- Import Routes and Waypoints from GPX files

#### Notes and Regions

- Display Notes and Regions available via `/resources/notes` and  `/resources/regions` paths
- View Note properties.
- Draw Regions and add Notes to them.
- Add, edit, move and delete Notes and associate them with Regions.

---

### Alarms and Notifications:

- Display alarms from received *Notification* messages _(visual and audio)_.
    - Depth
    - Closest Approach
    - "Buddy" notifications
- Raise alarms such as `Man overboard`, etc.

__Anchor Watch:__
- Set anchor drag alarm

---

### History Playback

Playback recorded time-series data captured on the Signal K server via the `playback` api.

---

### Instrument Panel:

Freeboard allows you to use your favourite instrumentation app installed on your Signal K server.

Select from installed applications in the `settings` screen and they will displayed in the instrument panel drawer.

_Instrument Panel `(@SignalK/InstrumentPanel)` will be displayed by default._

---

_**Freeboard** is a port of http://www.42.co.nz/freeboard for use with Signal K communication protocols and server features._

---

## System Requirements:

For all Freeboard features to be fully functional, it requires that the Signal K server in use be able to provide the necessary services for the following paths:

1. `reources/routes`, `resources/waypoints`, `resources/notes`, `resources/regions` - Serve resources as well as accept and persist resource data submitted to these paths.

2. `resources/charts` - Serve chart resources.

3. `navigation/anchor`, `notifications/navigation/anchor` - Serve and accept `position`, `maxRadius` values as well as calculate `currentRadius` and serve notifications.

4. `notifications/environment/depth` - Serve notifications for `belowKeel`, `belowSurface` `belowTransducer`.

5. `navigation/courseGreatCircle/activeRoute` - Serve and accept `href` & `startTime` values to allow a route to be set as active. It is expected that the server will initiate any subsequent calculations and related value updates.

6. `navigation/courseGreatCircle/nextPoint` - Serve and accept `position` values to allow a waypoint to be set as a destination. It is expected that the server will initiate any subsequent calculations and related value updates.

7. **Playback History** - Implement the Signal K Playback api (`/signalk/v1/playback`)

These functions may be provided natively by the server or through the use of *plugins*.

For example the following plugins installed on the *Signal K node server* will enable full functionality:
- freeeboard-sk-helper _(Course information)_
- sk-resources-fs _(Routes, Waypoints, Notes & Regions provider)_
- @signalk/charts-plugin *(Charts provider)*
- signalk-anchoralarm-plugin *(anchor alarm settings & notifications)*
- signalk-simple-notifications *(depth alarm notifications)*

---

### Integrate Instrument Apps
![Server Instruments](https://user-images.githubusercontent.com/38519157/46716813-00d27080-ccad-11e8-98a3-ab4b4f47df11.png)

### Vessel Up Display
![Vessel Up](https://user-images.githubusercontent.com/38519157/46716759-cf59a500-ccac-11e8-9ac5-68a7f3429f4a.png)

### North Up Display
![North Up](https://user-images.githubusercontent.com/38519157/46716737-bc46d500-ccac-11e8-9d31-87cfffb1ad3b.PNG)

---

## Development:

Freeboard is an Angular project generated with [Angular CLI](https://github.com/angular/angular-cli).
It is recommended that the Angular CLI be installed globally `npm i -g @angular/cli@latest` prior to following the steps below.

1. Clone this repository.

2. Run `npm i` to install Angular CLI and project dependencies. *Note: this will also build the project placing the deployable application files in the `public` folder.*

3. Run `npm start` or `ng serve` to start a development web server and then navigate to `http://localhost:4200/` to load the application. The application will automatically reload once you save changes to any of the source files.

### Note:

The Freeboard application will look to connect to a Signal K server at the *ip address:port* contained in the url of your browser.

During development, if a Signal K server is not running on your development device, you are able to specify the Signal K server api / stream host you wish to connect to by editing the `DEV_SERVER` object in the `src/app.info.ts` file.
```
DEV_SERVER {
    host: '<IP_ADDRESS>',
    port; 3000,
    ssl: false
}
```

_Note: These settings apply in **Development Mode** only!_

    - `npm start`
    - `ng serve`
    - Files generated using `ng build`

_They will __NOT__ apply when using **Production Mode**, the generated application will attempt to connect to a Signal K api / stream on the hosting server._

    - `ng serve --prod`
    - Files generated by `ng build --prod`

---

### Building a Release:

#### Angular Build

To build the Freeboard application use the `ng build --prod` command.

Built application files for deployment are placed in the `/public` folder.

#### NPM package

To build the NPM package use `npm pack` command which will:
1. Build the application using `ng build --prod`.
2. Create the NPM package `*.tgz` file.

Built `*.tgz` file is placed in the `/` root folder.


text:
### Turbo Studio and Command Line

Turbo Studio, allows developers and systems administrators to build Turbo images through a friendly graphical user interface. Turbo Studio is most commonly used for it's "snapshot" method of containerization. Read more about Turbo Studio [here](/docs/reference#ide).

The command-line interface is a command line tool for creating containers and building images in real-time. The command-line interface also provides a suite of tools for managing containers and images.

**Developers** can use the command-line interface to containerize their entire developer stack into their application -- ensuring that the same product a developer sees is the one encountered by end-users.

**System administrators** can use the command-line interface to more effectively manage their infrastructure.

Read more about using the command-line interface [here](/docs/reference/command-line).


text:
# TheGraph -  Public Cloud Abstraction

### Infrastructure deployment in AWS Cloud

After installing all the preerquisites specified on [STEP 1](https://github.com/easy2stake/thegraph), follow the next steps in order to deploy on AWS Cloud.

### 1. Install AWS CLI

```sh
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

# Confirm it is installed
aws --version
aws-cli/2.2.27 Python/3.8.8 Linux/5.11.0-25-generic exe/x86_64.ubuntu.20 prompt/off
```
>**MACOS USERS:** please use any version < 2.2.24. curently there is a bug in this version
**More details here:** https://github.com/aws/aws-cli/pull/6289

### 2. Configure aws cli
```sh
aws configure
AWS Access Key ID [None]: <YOUR-AWS-ACCESS-KEY>
AWS Secret Access Key [None]: <YOUR-AWS-SECRET-ACCESS-KEY>
Default region name [None]: us-west-2 #Choose your prefered default region here
Default output format [None]:

# The configuration will be stored here
$HOME/.aws #This is used by terraform to login and deploy the infrastructure
```
### 3. Install aws iam authenticator

```sh
curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator
chmod +x ./aws-iam-authenticator
sudo cp ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator

# Confirm it's working
aws-iam-authenticator version
{"Version":"v0.5.0","Commit":"1cfe2a90f68381eacd7b6dcfa2bf689e76eb8b4b"}
```

### 4. Deploy the kubernetes cluster:
```sh
# Initialize the working directory
terraform init
# Look for the "Terraform has been successfully initialized!" to confirm everything worked

# Preview the changes that Terraform plans to make to your infrastructure
terraform plan  -out=myplan.zip
# The output will be big, listing all the resources pending to be deployed on the public cloud

# Execute the actions proposed in a Terraform plan.
terraform apply "myplan.zip"
# Run and wait. It needs time to create the kubernetes cluster, the DB and all other necessary resources.
```
When the deploy job finishes you'll be prompted with the "egress" ip addresses of your cluster.
Save the two IP addresses mentioned under the next line (your IPs will be different than the ones below):
```sh
IPs assigned to NAT Gateways that should be added in specific firewalls that protects ETH endpoints, other resources:
<IP_ADDRESS>
<IP_ADDRESS>
```
These are the outbound (public) IP addresses of your "thegraph-nodes". Whitelist where is needed depending on your needs. EX: You might want to whitelist these IP addresses under your ETH RPC NODES / Archive nodes and so on.

### 5. Configure kubectl

```sh
aws eks list-clusters
{
    "clusters": [
        "theGraph-EKS-CLS"
    ]
}

# Use the cluster name from above into the next command
aws eks update-kubeconfig --name theGraph-EKS-CLS
Added new context arn:aws:eks:us-west-2:069157684607:cluster/theGraph-EKS-CLS to /home/YOUR_USER/.kube/config
```

**Confirm that you're connected to the Kubernetes Cluster:**
```sh
kubectl get pods --all-namespaces
NAMESPACE            NAME                                       READY   STATUS    RESTARTS   AGE
ingress-controller   ingress-nginx-controller-b65df6fbb-2kpll   1/1     Running   0          6m40s
kube-system          aws-node-b7nkz                             1/1     Running   0          25m
kube-system          aws-node-xg6r6                             1/1     Running   0          25m
kube-system          coredns-86d9946576-h5v5f                   1/1     Running   0          28m
kube-system          coredns-86d9946576-vdplt                   1/1     Running   0          28m
kube-system          kube-proxy-p2lq2                           1/1     Running   0          25m
kube-system          kube-proxy-tpzxk                           1/1     Running   0          25m

# You should see and output similar to this one
```

repository: cmalfesi/thegraph

repo_name: cmalfesi/thegraph


text:
## Flakey.models

#### Defining Models
You can define models for your app by extending Flakey.models.Model.

    class Note extends Flakey.models.Model
      @model_name: 'Note',
      @fields: ['id', 'name', 'content']

      # This is a class method
      @foo: () ->
        return "This is a class method"

      # These are instance methods
      as_markdown: () ->
        return this.content

      as_html: () ->
        # Using the Showdown Markdown -> HTML converter
        converter = new Showdown.converter()
        return converter.makeHtml(this.content);

As you can see from the code above, defining a model is very simple. Simply create a new class that extends Flakey.models.Model, set it's model_name parameter to match the name of the class (in this case *Note*), and set the fields parameter to an array fields for this model. This *must* include an id field in addition to you data fields.

#### Creating a new instance
Now that we've defined our model, we can start using it. We can instantiate it a new Note like this:

    # Using the init field shorthand
    grocerys = new Note {
      name: "Grocery List"
    }

    # Not using the shorthand
    grocerys = new Note()
    grocerys.name = "Grocery List"

    grocerys.save()

This creates a new instance of Note and sets its name field to "Grocery List". Finally we save it. Save a model will generate a diff of each of it's fields, and push the difference onto the `grocerys.versions` array. Then the model is written into each of the activated storage backends.

#### About storage backends
Storage backends are methods of saving models for later use. By default the memory backend (an object located at window.memcache) and the localStorage backend are enabled. Via settings, you can enable the server (ajax storage) and socketio (realtime server storage with push updates).

When an model instance is saved, it is written to each enabled storage backend. If for some reason saving to a backend fails (like a network interruption), a transaction log is generated and stored in localStorage listing in order the transactions which failed. When ever a new transaction is requested, a backend will check it's log for any pending transactions. If some exist, it will push the new transaction onto the end of the array and attempt to perform the first transaction. If it succeeds, it continues until either another failure or the log is empty.

At page load, it's important to sync each of the storage backends. This is done by calling `Flakey.models.backend_controller.sync('Note')` where the string parameter is the name of your model. This should be called once for each of the models in you app, just after you call `Flakey.init(settings)`. Model sync will try to execute any pending log transactions, and then will compare and sync the objects stored in each. This makes it possible to use a volatile backend (like 'memory') for read actions, thereby reducing server traffic.

#### Version History
First lets add some data so that we have a history to play with:

    # Create a new revision on grocerys
    grocerys.content = "# Grocery List
     - Milk
     - Eggs"
    grocerys.save()

    # Add another item to the list
    grocerys.content = "# Grocery List
     - Milk
     - Eggs
     - Cheese"
    grocerys.save()

Now that we have a few versions, we can start to use nifty features of Flakey.js:

    # Get a view of grocerys to before we added 'cheese' to the list
    # inital save == version 0, so we want version 1
    i = 1
    time = new Date(note.versions[i].time)
    rev = grocerys.evolve(grocerys.versions[i].version_id)

    console.log time        # The timestamp of when this version was created

    console.log rev.name    # "Grocery List"

    console.log rev.content # "# Grocery List
                            #  - Milk
                            #  - Eggs"

That code lets us non-destructively look at a model instance's past without altering the actual model. What if we want to completely destroy the model current state and rollback to the last version? That's even easier:

    # Destroy the latest version
    # rollback() can accept an integer (rollback N versions) or a
    # version_id (rollback to that version)
    grocerys.rollback(1)

This snippet pops the latest version from the array and writes it to the enabled storage backends. Please note: Calling rollback() is *not* reversible. It is destructive to any of the versions its deleting, and therefore potentially very dangerous. Please take care when using it.

license: ISC


text:
## About Airam

Airam is an easy-to-start web development framework, focused on providing the developer with an understandable environment using familiar template syntax and Component-oriented flow, router-centric, and looking similar to the early days of Angular2.

- Router based on FastRouter.
- Dependency injection container accessible from the application instance.
- Fast template engine optimized for production.
- Build container function network and template elements

repository: egarciahz/airam

gha_language: PHP

repo_name: egarciahz/airam


text:
# Salesforce Test Factory Base

Usage:

    // Instantiate a new instance of the base factory
    TestFactoryBase base = new TestFactoryBase();

    // The Base Factory will attempt to pre-fill all the fields that are
    // required and typically used for a specific SObject
    Account acct = (Account)base.buildSObject(new Account());
    insert acct;

    // You can also assign values into the object constructor which will
    // override the defaults.
    //
    // This also works when you are requesting a specific ObjectDefinition!!
    Contact con = (Contact)base.createSObject(new Contact(AccountId = acct.Id));

    // You can also specify a specific set of overrides to define the shape of an object
    Account customer = (Account)base.createSObject(new Account(), 'CustomerDef');

    // You can also specify a number of records you'd like to create
    List<Account> accts = base.createSObjectList(new Account(), 200);

    /***********************************************************************************************
    *   Build vs Create Methods
    ***********************************************************************************************/

    // Build methods will setup and return the object(s) without inserting it
    Account acct = (Account)base.buildSObject(new Account());

    // Create methods will setup and insert the object(s) thats returned
    Account acct = (Account)base.createSObject(new Account());

    /***********************************************************************************************
    *   Name Field Map Configuration
    ***********************************************************************************************/

    // Update the map with SObject => Field API Name pairing for special objects that don't have a
    // standard Name field or have an auto numbered Name field for incrementing in bulk requests
    private Map<String, String> nameFieldMap = new Map<String, String> {
        'Contact' => 'LastName',
        'Case'    => 'Subject'
    };

    /***********************************************************************************************
    *   TestFactoryBase is Extendable
    ***********************************************************************************************/

    // You can use it to borrow Base test methods in existing or new
    // object test factories
    public class AccountTestFactory extends TestFactoryBase {}

    // You can leverage the same Factory Base methods from the object test factory
    AccountTestFactory acctFactory = new AccountTestFactory();
    Account acct = (Account)acctFactory.buildSObject(new Account());

    /***********************************************************************************************
    *   You can also build your own object configurations by implementing
    *   the ObjectDefinition interface and storing the class into the
    *   associated [SObject]TestFactory.
    *
    *   NOTE: Each ObjectDefinition should end with the 'Def' suffix
    *         in order for the framework to identify the appropriate
    *         definition.
    ***********************************************************************************************/

    public class CustomerDef implements ObjectDefinition {
        public Map<String, Object> getDefinition() {
            return new Map<String, Object> {
                'Name'         => 'Test Customer',
                'Type'         => 'Customer',
                'RecordTypeId' => AccountConstants.RECORD_TYPE_CUSTOMER_ID
            };
        }
    }