--- - arguments: [] command: - astyle documentation: - http://astyle.sourceforge.net/astyle.html enabled: true image: restyled/restyler-astyle:v3.6.2 include: - "**/*.c" - "**/*.cc" - "**/*.cpp" - "**/*.cxx" - "**/*.c++" - "**/*.C" - "**/*.cs" - "**/*.h" - "**/*.hh" - "**/*.hpp" - "**/*.hxx" - "**/*.h++" - "**/*.H" - "**/*.m" - "**/*.mm" interpreters: [] metadata: languages: - C - C++ - C# - Java* - Objective-C tests: - contents: | int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; } extension: name: restyled: | int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; } support: - contents: | /* FEOF example */ #include int main() { FILE * pFile; char buffer [100]; pFile = fopen ("myfile.txt" , "r"); if (pFile == NULL) perror ("Error opening file"); else { while ( ! feof (pFile) ) { if ( fgets (buffer , 100 , pFile) == NULL ) break; fputs (buffer , stdout); } fclose (pFile); } return 0; } extension: name: restyled: | /* FEOF example */ #include int main() { FILE * pFile; char buffer [100]; pFile = fopen ("myfile.txt", "r"); if (pFile == NULL) perror ("Error opening file"); else { while (! feof (pFile) ) { if ( fgets (buffer, 100, pFile) == NULL ) break; fputs (buffer, stdout); } fclose (pFile); } return 0; } support: name: astyle run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - autopep8 - "--in-place" documentation: - https://github.com/hhatto/autopep8 enabled: true image: restyled/restyler-autopep8:v2.3.1 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | import math, sys; def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple=( 1,2, 3,'a' ); some_variable={'long':'Long code lines should be wrapped within 79 characters.', 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, 20,300,40000,500000000,60000000000000000]}} return (some_tuple, some_variable) extension: name: restyled: | import math import sys def example1(): # This is a long comment. This should be wrapped to fit within 72 characters. some_tuple = (1, 2, 3, 'a') some_variable = {'long': 'Long code lines should be wrapped within 79 characters.', 'other': [math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on'], 'more': {'inner': 'This whole logical line should be wrapped.', some_tuple: [1, 20, 300, 40000, 500000000, 60000000000000000]}} return (some_tuple, some_variable) support: name: autopep8 run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - black documentation: - https://github.com/python/black enabled: true image: restyled/restyler-black:v24.8.0 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | import math, sys; def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple=( 1,2, 3,'a' ); some_variable={'long':'Long code lines should be wrapped within 79 characters.', 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, 20,300,40000,500000000,60000000000000000]}} return (some_tuple, some_variable) extension: name: restyled: | import math, sys def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple = (1, 2, 3, "a") some_variable = { "long": "Long code lines should be wrapped within 79 characters.", "other": [ math.pi, 100, 200, 300, 9876543210, "This is a long string that goes on", ], "more": { "inner": "This whole logical line should be wrapped.", some_tuple: [1, 20, 300, 40000, 500000000, 60000000000000000], }, } return (some_tuple, some_variable) support: name: black run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - brittany - "--write-mode=inplace" documentation: - https://github.com/lspitzner/brittany - https://github.com/restyled-io/restyled.io/wiki/Common-Errors:-Brittany enabled: false image: restyled/restyler-brittany:v0.14.0.2 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: | func (MyLongFoo abc def) = 1 func (Bar a d) = 2 func _ = 3 extension: name: restyled: | func (MyLongFoo abc def) = 1 func (Bar a d ) = 2 func _ = 3 support: name: brittany run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - cabal-fmt - "--inplace" documentation: - https://github.com/phadej/cabal-fmt enabled: false image: restyled/restyler-cabal-fmt:v0.1.6 include: - "**/*.cabal" interpreters: [] metadata: languages: - Haskell tests: - contents: | cabal-version: 2.4 name: cabal-fmt version: 0 -- An example formatter executable cabal-fmt default-language: Haskell2010 hs-source-dirs: src main-is: CabalFmt.hs -- build depends will be in -- a nice tabular format build-depends: base >=4.11 && <4.13, pretty >=1.1.3.6 && <1.2, bytestring, Cabal ^>=2.5, containers ^>=0.5.11.0 || ^>=0.6.0.1 -- extensions will be sorted other-extensions: DeriveFunctor FlexibleContexts ExistentialQuantification OverloadedStrings RankNTypes extension: name: restyled: | cabal-version: 2.4 name: cabal-fmt version: 0 -- An example formatter executable cabal-fmt default-language: Haskell2010 hs-source-dirs: src main-is: CabalFmt.hs -- build depends will be in -- a nice tabular format build-depends: , base >=4.11 && <4.13 , bytestring , Cabal ^>=2.5 , containers ^>=0.5.11.0 || ^>=0.6.0.1 , pretty >=1.1.3.6 && <1.2 -- extensions will be sorted other-extensions: DeriveFunctor ExistentialQuantification FlexibleContexts OverloadedStrings RankNTypes support: name: cabal-fmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - clang-format - "-i" documentation: - https://clang.llvm.org/docs/ClangFormat.html enabled: true image: restyled/restyler-clang-format:v18.1.8 include: - "**/*.c" - "**/*.cc" - "**/*.cpp" - "**/*.cxx" - "**/*.c++" - "**/*.C" - "**/*.cs" - "**/*.h" - "**/*.hh" - "**/*.hpp" - "**/*.hxx" - "**/*.h++" - "**/*.H" - "**/*.java" - "**/*.js" - "**/*.m" interpreters: [] metadata: languages: - C - C++ - Java - JavaScript - Objective-C - Protobuf - C# tests: - contents: | int formatted_code; void unformatted_code ; void formatted_code_again; extension: name: restyled: | int formatted_code; void unformatted_code; void formatted_code_again; support: name: clang-format run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - cmake-format - "--in-place" documentation: - https://github.com/cheshirekow/cmake_format enabled: true image: restyled/restyler-cmake-format:0.6.13-1 include: - "**/CMakeLists.txt" - "**/*.cmake-format-test" interpreters: [] metadata: languages: - CMake tests: - contents: | # The following multiple newlines should be collapsed into a single newline cmake_minimum_required(VERSION 2.8.11) project(cmakelang_test) # This multiline-comment should be reflowed # into a single comment # on one line # This comment should remain right before the command call. # Furthermore, the command call should be formatted # to a single line. add_subdirectories(foo bar baz foo2 bar2 baz2) # This very long command should be wrapped set(HEADERS very_long_header_name_a.h very_long_header_name_b.h very_long_header_name_c.h) # This command should be split into one line per entry because it has a long argument list. set(SOURCES source_a.cc source_b.cc source_d.cc source_e.cc source_f.cc source_g.cc source_h.cc) # The string in this command should not be split set_target_properties(foo bar baz PROPERTIES COMPILE_FLAGS "-std=c++11 -Wall -Wextra") # This command has a very long argument and can't be aligned with the command # end, so it should be moved to a new line with block indent + 1. some_long_command_name("Some very long argument that really needs to be on the next line.") # This situation is similar but the argument to a KWARG needs to be on a # newline instead. set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-sign-compare -Wno-unused-parameter -xx") set(HEADERS header_a.h header_b.h # This comment should # be preserved, moreover it should be split # across two lines. header_c.h header_d.h) # This part of the comment should # be formatted # but... # cmake-format: off # This bunny should remain untouched: # .   _ ∩ #   レヘヽ| | #     (・x・) #    c( uu} # cmake-format: on # while this part should # be formatted again # This is a paragraph # # This is a second paragraph # # This is a third paragraph # This is a comment # that should be joined but # TODO(josh): This todo should not be joined with the previous line. # NOTE(josh): Also this should not be joined with the todo. if(foo) if(sbar) # This comment is in-scope. add_library(foo_bar_baz foo.cc bar.cc # this is a comment for arg2 # this is more comment for arg2, it should be joined with the first. baz.cc) # This comment is part of add_library other_command(some_long_argument some_long_argument) # this comment is very long and gets split across some lines other_command(some_long_argument some_long_argument some_long_argument) # this comment is even longer and wouldn't make sense to pack at the end of the command so it gets it's own lines endif() endif() # This very long command should be broken up along keyword arguments foo(nonkwarg_a nonkwarg_b HEADERS a.h b.h c.h d.h e.h f.h SOURCES a.cc b.cc d.cc DEPENDS foo bar baz) # This command uses a string with escaped quote chars foo(some_arg some_arg "This is a \"string\" within a string") # This command uses an empty string foo(some_arg some_arg "") # This command uses a multiline string foo(some_arg some_arg " This string is on multiple lines ") # No, I really want this to look ugly # cmake-format: off add_library(a b.cc c.cc d.cc e.cc) # cmake-format: on extension: ".cmake-format-test" name: README example restyled: | # The following multiple newlines should be collapsed into a single newline cmake_minimum_required(VERSION 2.8.11) project(cmakelang_test) # This multiline-comment should be reflowed into a single comment on one line # This comment should remain right before the command call. Furthermore, the # command call should be formatted to a single line. add_subdirectories(foo bar baz foo2 bar2 baz2) # This very long command should be wrapped set(HEADERS very_long_header_name_a.h very_long_header_name_b.h very_long_header_name_c.h) # This command should be split into one line per entry because it has a long # argument list. set(SOURCES source_a.cc source_b.cc source_d.cc source_e.cc source_f.cc source_g.cc source_h.cc) # The string in this command should not be split set_target_properties(foo bar baz PROPERTIES COMPILE_FLAGS "-std=c++11 -Wall -Wextra") # This command has a very long argument and can't be aligned with the command # end, so it should be moved to a new line with block indent + 1. some_long_command_name( "Some very long argument that really needs to be on the next line.") # This situation is similar but the argument to a KWARG needs to be on a newline # instead. set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-sign-compare -Wno-unused-parameter -xx") set(HEADERS header_a.h header_b.h # This comment should be preserved, moreover it should # be split across two lines. header_c.h header_d.h) # This part of the comment should be formatted but... # cmake-format: off # This bunny should remain untouched: # .   _ ∩ #   レヘヽ| | #     (・x・) #    c( uu} # cmake-format: on # while this part should be formatted again # This is a paragraph # # This is a second paragraph # # This is a third paragraph # This is a comment that should be joined but # TODO(josh): This todo should not be joined with the previous line. # NOTE(josh): Also this should not be joined with the todo. if(foo) if(sbar) # This comment is in-scope. add_library( foo_bar_baz foo.cc bar.cc # this is a comment for arg2 this is more comment for arg2, # it should be joined with the first. baz.cc) # This comment is part of add_library other_command( some_long_argument some_long_argument) # this comment is very long and # gets split across some lines other_command( some_long_argument some_long_argument some_long_argument) # this comment # is even longer # and wouldn't # make sense to # pack at the # end of the # command so it # gets it's own # lines endif() endif() # This very long command should be broken up along keyword arguments foo(nonkwarg_a nonkwarg_b HEADERS a.h b.h c.h d.h e.h f.h SOURCES a.cc b.cc d.cc DEPENDS foo bar baz) # This command uses a string with escaped quote chars foo(some_arg some_arg "This is a \"string\" within a string") # This command uses an empty string foo(some_arg some_arg "") # This command uses a multiline string foo(some_arg some_arg " This string is on multiple lines ") # No, I really want this to look ugly # cmake-format: off add_library(a b.cc c.cc d.cc e.cc) # cmake-format: on support: name: cmake-format run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - dart - format documentation: - https://pub.dev/packages/dart_style enabled: true image: restyled/restyler-dart-format:v2.3.4 include: - "**/*.dart" interpreters: [] metadata: languages: - Dart tests: - contents: | void example() { if (tag=='style'||tag=='script'&&(type==null||type == TYPE_JS ||type==TYPE_DART)|| tag=='link'&&(rel=='stylesheet'||rel=='import')) {} } extension: name: dart_style example restyled: | void example() { if (tag == 'style' || tag == 'script' && (type == null || type == TYPE_JS || type == TYPE_DART) || tag == 'link' && (rel == 'stylesheet' || rel == 'import')) {} } support: name: dart-format run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - dfmt - "--inplace" documentation: - https://github.com/dlang-community/dfmt#readme enabled: true image: restyled/restyler-dfmt:v0.14.2 include: - "**/*.d" interpreters: [] metadata: languages: - D tests: - contents: | void main(string[] args) { bool optionOne, optionTwo, optionThree; getopt(args, "optionOne", &optionOne, "optionTwo", &optionTwo, "optionThree", &optionThree); } extension: name: restyled: | void main(string[] args) { bool optionOne, optionTwo, optionThree; getopt(args, "optionOne", &optionOne, "optionTwo", &optionTwo, "optionThree", &optionThree); } support: name: dfmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: - format - "--inplace" command: - dhall documentation: - https://docs.dhall-lang.org enabled: true image: restyled/restyler-dhall-format:1.42.1 include: - "**/*.dhall" interpreters: [] metadata: languages: - Dhall tests: - contents: | let Fruit_ = < Apple : {} | Banana : {} | Orange : {} > in let fruiteHandler_ = { Apple = \(_ : {}) -> "Apple" , Banana = \(_ : {}) -> "Banana" , Orange = \(_ : {}) -> "Orange" } in let f = { Fruit = Fruit_, fruitToText = \(f : Fruit_) -> merge fruiteHandler_ f } in let x = { fruit1 = f.fruitToText (f.Fruit.Apple {=}), fruit2 = f.fruitToText (f.Fruit.Banana {=}) } in x // { fruit1 = f.fruitToText (f.Fruit.Orange {=}) } extension: name: restyled: | let Fruit_ = < Apple : {} | Banana : {} | Orange : {} > in let fruiteHandler_ = { Apple = \(_ : {}) -> "Apple" , Banana = \(_ : {}) -> "Banana" , Orange = \(_ : {}) -> "Orange" } in let f = { Fruit = Fruit_ , fruitToText = \(f : Fruit_) -> merge fruiteHandler_ f } in let x = { fruit1 = f.fruitToText (f.Fruit.Apple {=}) , fruit2 = f.fruitToText (f.Fruit.Banana {=}) } in x // { fruit1 = f.fruitToText (f.Fruit.Orange {=}) } support: name: dhall-format run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - dotnet-format-files documentation: - https://github.com/dotnet/format enabled: false image: restyled/restyler-dotnet-format:v5.1.250801 include: - "**/*.cs" - "**/*.vb" interpreters: [] metadata: languages: - C# - VB.NET tests: - contents: | int formatted_code; void unformatted_code ; void formatted_code_again; extension: cs name: restyled: | int formatted_code; void unformatted_code; void formatted_code_again; support: contents: | Exe netcoreapp3.1 path: project.csproj - contents: | int formatted_code; void unformatted_code ; void formatted_code_again; extension: cs name: restyled: | int formatted_code; void unformatted_code; void formatted_code_again; support: contents: | Exe netcoreapp3.1 path: project.csproj name: dotnet-format run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - elm-format - "--yes" documentation: - https://github.com/avh4/elm-format enabled: true image: restyled/restyler-elm-format:v0.6.1-alpha-3 include: - "**/*.elm" interpreters: [] metadata: languages: - Elm tests: - contents: | homeDirectory = "/root/files" eval boolean = case boolean of Literal bool -> bool Not b -> not (eval b) And b b_ -> eval b && eval b_ Or b b_ -> eval b || eval b_ extension: name: restyled: | module Main exposing (eval, homeDirectory) homeDirectory = "/root/files" eval boolean = case boolean of Literal bool -> bool Not b -> not (eval b) And b b_ -> eval b && eval b_ Or b b_ -> eval b || eval b_ support: name: elm-format run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - fantomas documentation: - https://github.com/fsprojects/fantomas enabled: true image: restyled/restyler-fantomas:v3.3.0 include: - "**/*.fs" - "**/*.fsi" - "**/*.fsx" interpreters: [] metadata: languages: - F# tests: - contents: | type Type = TyLam of Type * Type | TyVar of string | TyCon of string * Type list with override this.ToString () = match this with | TyLam (t1, t2) -> sprintf "(%s -> %s)" (t1.ToString()) (t2.ToString()) | TyVar a -> a | TyCon (s, ts) -> s extension: fs name: restyled: | type Type = | TyLam of Type * Type | TyVar of string | TyCon of string * Type list override this.ToString() = match this with | TyLam(t1, t2) -> sprintf "(%s -> %s)" (t1.ToString()) (t2.ToString()) | TyVar a -> a | TyCon(s, ts) -> s support: - contents: | let Multiple9x9 () = for i in 1 .. 9 do printf "\n"; for j in 1 .. 9 do let k = i * j in printf "%d x %d = %2d " i j k; done; done;; Multiple9x9 ();; extension: fs name: restyled: | let Multiple9x9() = for i in 1 .. 9 do printf "\n" for j in 1 .. 9 do let k = i * j printf "%d x %d = %2d " i j k Multiple9x9() support: name: fantomas run_as_filter: false supports_arg_sep: false supports_multiple_paths: false - arguments: [] command: - fourmolu - "--mode" - inplace documentation: - https://fourmolu.github.io/ - https://github.com/fourmolu/fourmolu enabled: false image: restyled/restyler-fourmolu:v0.16.2.0 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: | foo :: MonadIO m -> Text -> Text -> SqlPersistT m () foo = undefined extension: name: restyled: | foo :: MonadIO m -> Text -> Text -> SqlPersistT m () foo = undefined support: name: fourmolu run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - gn - format documentation: - https://gn.googlesource.com/gn/+/master/docs/reference.md#cmd_format enabled: true image: restyled/restyler-gn:v2 include: - "**/*.gn" - "**/*.gni" interpreters: [] metadata: languages: - GN tests: - contents: 'sources = ["b", "a"] ' extension: gn name: restyled: | sources = [ "a", "b", ] support: name: gn run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - gofmt - "-w" documentation: - https://golang.org/cmd/gofmt/ enabled: true image: restyled/restyler-gofmt:go1.23.0 include: - "**/*.go" interpreters: [] metadata: languages: - Go tests: - contents: | package main import "fmt" // this is demo to format code // with gofmt command var a int=2; var b int=5; var c string= `hello world`; func print(){ fmt.Println("Value for a,b and c is : "); fmt.Println(a); fmt.Println((b)); fmt.Println(c); } extension: name: restyled: "package main\n\nimport \"fmt\"\n\n// this is demo to format code\n// with gofmt command\nvar a int = 2\nvar b int = 5\nvar c string = `hello world`\n\nfunc print() {\n\tfmt.Println(\"Value for a,b and c is : \")\n\tfmt.Println(a)\n\tfmt.Println((b))\n\tfmt.Println(c)\n}\n" support: name: gofmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - google-java-format - "--replace" documentation: - https://github.com/google/google-java-format#readme enabled: false image: restyled/restyler-google-java-format:v1.9 include: - "**/*.java" interpreters: [] metadata: languages: - Java tests: - contents: | private enum Answer { YES { @Override public String toString() { return "yes"; } }, NO, MAYBE } extension: java name: restyled: | private enum Answer { YES { @Override public String toString() { return "yes"; } }, NO, MAYBE } support: name: google-java-format run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - hindent documentation: - https://github.com/commercialhaskell/hindent enabled: false image: restyled/restyler-hindent:v6.1.1 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: 'example = case x of Just p -> foo bar ' extension: name: restyled: | example = case x of Just p -> foo bar support: name: hindent run_as_filter: false supports_arg_sep: false supports_multiple_paths: false - arguments: [] command: - hlint - "--refactor" - "--refactor-options=-i" documentation: - https://github.com/ndmitchell/hlint#readme - https://github.com/restyled-io/restyled.io/wiki/Common-Errors:-HLint enabled: false image: restyled/restyler-hlint:v3.5 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: | main :: IO () main = putStrLn $ "hello hlint" extension: name: restyled: | main :: IO () main = putStrLn "hello hlint" support: name: hlint run_as_filter: false supports_arg_sep: true supports_multiple_paths: false - arguments: [] command: - isort documentation: - https://github.com/timothycrosley/isort/ enabled: true image: restyled/restyler-isort:v5.13.2 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | from my_lib import Object import os from my_lib import Object3 from my_lib import Object2 import sys from third_party import lib15, lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11, lib12, lib13, lib14 import sys from __future__ import absolute_import from third_party import lib3 print("Hey") print("yo") extension: name: restyled: | from __future__ import absolute_import import os import sys from my_lib import Object, Object2, Object3 from third_party import (lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11, lib12, lib13, lib14, lib15) print("Hey") print("yo") support: name: isort run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - formatter documentation: - https://code.revelc.net/formatter-maven-plugin/ enabled: false image: restyled/restyler-jdt:v2.13.0 include: - "**/*.java" - "**/*.css" - "**/*.html" - "**/*.json" - "**/*.xml" interpreters: [] metadata: languages: - Java - JavaScript* - CSS - HTML - JSON - XML tests: - contents: | public class ShouldFormat1 { int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; } } extension: java name: restyled: | public class ShouldFormat1 { int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; } } support: contents: | 4.0.0 fooGroup fooArtifact 0.0.0-SNAPSHOT path: pom.xml - contents: | public class ShouldFormat2 { int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; }} extension: java name: restyled: | public class ShouldFormat2 { int Foo(bool isBar) { if (isBar) { bar(); return 1; } else return 0; } } support: contents: | 4.0.0 fooGroup fooArtifact 0.0.0-SNAPSHOT path: pom.xml name: jdt run_as_filter: false supports_arg_sep: false supports_multiple_paths: true - arguments: [] command: - jq-write documentation: - https://stedolan.github.io/jq/ enabled: false image: restyled/restyler-jq:v1.6-3 include: - "**/*.json" interpreters: [] metadata: languages: - JSON tests: - contents: | { "foo": "bar" , "baz": "bat" } extension: name: restyled: | { "foo": "bar", "baz": "bat" } support: name: jq run_as_filter: false supports_arg_sep: false supports_multiple_paths: false - arguments: [] command: - lua-format - "--in-place" documentation: - https://github.com/Koihik/LuaFormatter enabled: true image: restyled/restyler-luaformatter:v1.3.6 include: - "**/*.lua" interpreters: - lua metadata: languages: - Lua tests: - contents: | matrix = { {1, 0, 0, 0}, {1, 1, 0, 0}, {1, 1, 1, 0}, {1, 1, 1, 1} } extension: name: Matrix restyled: 'matrix = {{1, 0, 0, 0}, {1, 1, 0, 0}, {1, 1, 1, 0}, {1, 1, 1, 1}} ' support: name: luaformatter run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - nixfmt documentation: - https://github.com/NixOS/nixfmt#readme enabled: true image: restyled/restyler-nixfmt:v0.6.0 include: - "**/*.nix" interpreters: [] metadata: languages: - Nix tests: - contents: | let /* * What you're seeing here is our nix formatter. It's quite opinionated: */ sample-01 = { lib }: { list = [ elem1 elem2 elem3 ] ++ lib.optionals stdenv.isDarwin [ elem4 elem5 ]; # and not quite finished }; # it will preserve your newlines sample-02 = { stdenv, lib }: { list = [ elem1 elem2 elem3 ] ++ lib.optionals stdenv.isDarwin [ elem4 elem5 ] ++ lib.optionals stdenv.isLinux [ elem6 ] ; }; # but it can handle all nix syntax, # and, in fact, all of nixpkgs in <20s. # The javascript build is quite a bit slower. sample-03 = { stdenv, system }: assert system == "i686-linux"; stdenv.mkDerivation { }; # these samples are all from https://github.com/nix-community/nix-fmt/tree/master/samples sample-simple = # Some basic formatting { empty_list = [ ]; inline_list = [ 1 2 3 ]; multiline_list = [ 1 2 3 4 ]; inline_attrset = { x = "y"; }; multiline_attrset = { a = 3; b = 5; }; # some comment over here fn = x: x + x; relpath = ./hello; abspath = /hello; # URLs get converted from strings url = "https://foobar.com"; atoms = [ true false null ]; # Combined listOfAttrs = [ { attr1 = 3; attr2 = "fff"; } { attr1 = 5; attr2 = "ggg"; } ]; # long expression attrs = { attr1 = short_expr; attr2 = if true then big_expr else big_expr; }; } ; in [ sample-01 sample-02 sample-03 ] extension: name: Online demo restyled: | let # * What you're seeing here is our nix formatter. It's quite opinionated: sample-01 = { lib }: { list = [ elem1 elem2 elem3 ] ++ lib.optionals stdenv.isDarwin [ elem4 elem5 ]; # and not quite finished }; # it will preserve your newlines sample-02 = { stdenv, lib }: { list = [ elem1 elem2 elem3 ] ++ lib.optionals stdenv.isDarwin [ elem4 elem5 ] ++ lib.optionals stdenv.isLinux [ elem6 ]; }; # but it can handle all nix syntax, # and, in fact, all of nixpkgs in <20s. # The javascript build is quite a bit slower. sample-03 = { stdenv, system }: assert system == "i686-linux"; stdenv.mkDerivation { }; # these samples are all from https://github.com/nix-community/nix-fmt/tree/master/samples sample-simple = # Some basic formatting { empty_list = [ ]; inline_list = [ 1 2 3 ]; multiline_list = [ 1 2 3 4 ]; inline_attrset = { x = "y"; }; multiline_attrset = { a = 3; b = 5; }; # some comment over here fn = x: x + x; relpath = ./hello; abspath = /hello; # URLs get converted from strings url = "https://foobar.com"; atoms = [ true false null ]; # Combined listOfAttrs = [ { attr1 = 3; attr2 = "fff"; } { attr1 = 5; attr2 = "ggg"; } ]; # long expression attrs = { attr1 = short_expr; attr2 = if true then big_expr else big_expr; }; }; in [ sample-01 sample-02 sample-03 ] support: name: nixfmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - nixpkgs-fmt documentation: - https://github.com/nix-community/nixpkgs-fmt#readme enabled: false image: restyled/restyler-nixpkgs-fmt:v1.3.0 include: - "**/*.nix" interpreters: [] metadata: languages: - Nix tests: - contents: | {foo,bar}: foo+bar extension: name: Online demo restyled: | { foo, bar }: foo + bar support: name: nixpkgs-fmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - npm-groovy-lint - "--fix" documentation: - https://github.com/nvuillam/npm-groovy-lint#readme enabled: true image: restyled/restyler-npm-groovy-lint:v15.0.2 include: - "**/*.groovy" interpreters: [] metadata: languages: - Groovy tests: - contents: | def variable = 1; pipeline { agent any options{ timestamps() } stages{ stage('') { steps { sh """ """ } } stage('Deploy') { steps { ansiColor('xterm') { sh """ """ } } } } } extension: name: restyled: | def variable = 1 pipeline { agent any options { timestamps() } stages { stage('') { steps { sh ''' ''' } } stage('Deploy') { steps { ansiColor('xterm') { sh ''' ''' } } } } } support: name: npm-groovy-lint run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - ocamlformat - "--inplace" documentation: - https://github.com/ocaml-ppx/ocamlformat enabled: true image: restyled/restyler-ocamlformat:v0.26.2 include: - "**/*.ml" interpreters: [] metadata: languages: - OCaml tests: - contents: | let sum_of_squares num = num + 1 |> List.range 0 |> List.map ~f:square |> List.fold_left ~init:0 ~f:( + ) extension: name: restyled: | let sum_of_squares num = num + 1 |> List.range 0 |> List.map ~f:square |> List.fold_left ~init:0 ~f:( + ) support: contents: '' path: ".ocamlformat" name: ocamlformat run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - ormolu - "--mode" - inplace documentation: - https://github.com/tweag/ormolu#readme enabled: false image: restyled/restyler-ormolu:v0.5.3.0 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: | foo :: MonadIO m -> Text -> Text -> SqlPersistT m () foo = undefined extension: name: restyled: | foo :: MonadIO m -> Text -> Text -> SqlPersistT m () foo = undefined support: name: ormolu run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - perltidy - "-st" documentation: - https://perltidy.sourceforge.net/ enabled: true image: restyled/restyler-perltidy:v20230701 include: - "**/*.pl" - "**/*.pm" interpreters: [] metadata: languages: - Perl tests: - contents: | my $lines = 0; # checksum: #lines my $bytes = 0; # checksum: #bytes my $sum = 0; # checksum: system V sum my $patchdata = 0; # saw patch data my $pos = 0; # start of patch data my $endkit = 0; # saw end of kit my $fail = 0; # failed extension: name: Some code with side comments restyled: | my $lines = 0; # checksum: #lines my $bytes = 0; # checksum: #bytes my $sum = 0; # checksum: system V sum my $patchdata = 0; # saw patch data my $pos = 0; # start of patch data my $endkit = 0; # saw end of kit my $fail = 0; # failed support: - contents: "$_= <<'EOL';\n $url = new URI::URL \"http://www/\"; die if $url eq \"xXx\";\nEOL\nLOOP:{print(\" digits\"),redo LOOP if/\\G\\d+\\b[,.;]?\\s*/gc;print(\" lowercase\"),\nredo LOOP if/\\G[a-z]+\\b[,.;]?\\s*/gc;print(\" UPPERCASE\"),redo LOOP \nif/\\G[A-Z]+\\b[,.;]?\\s*/gc;print(\" Capitalized\"),\nredo LOOP if/\\G[A-Z][a-z]+\\b[,.;]?\\s*/gc;\nprint(\" MiXeD\"),redo LOOP if/\\G[A-Za-z]+\\b[,.;]?\\s*/gc;print(\n\" alphanumeric\"),redo LOOP if/\\G[A-Za-z0-9]+\\b[,.;]?\\s*/gc;print(\" line-noise\"\n),redo LOOP if/\\G[^A-Za-z0-9]+/gc;print\". That's all!\\n\";}\n" extension: name: A loop restyled: | $_ = <<'EOL'; $url = new URI::URL "http://www/"; die if $url eq "xXx"; EOL LOOP: { print(" digits"), redo LOOP if /\G\d+\b[,.;]?\s*/gc; print(" lowercase"), redo LOOP if /\G[a-z]+\b[,.;]?\s*/gc; print(" UPPERCASE"), redo LOOP if /\G[A-Z]+\b[,.;]?\s*/gc; print(" Capitalized"), redo LOOP if /\G[A-Z][a-z]+\b[,.;]?\s*/gc; print(" MiXeD"), redo LOOP if /\G[A-Za-z]+\b[,.;]?\s*/gc; print(" alphanumeric"), redo LOOP if /\G[A-Za-z0-9]+\b[,.;]?\s*/gc; print(" line-noise"), redo LOOP if /\G[^A-Za-z0-9]+/gc; print ". That's all!\n"; } support: - contents: | %unitscale=("in",72,"pt",72.27/72,"pc",12,"mm",72/25.4,"cm",72/2.54, "\\hsize",100,"\\vsize",100,"\\textwidth",100,"\\textheight",100, "\\pagewidth",100,"\\linewidth",100); extension: name: A hash definition list restyled: | %unitscale = ( "in", 72, "pt", 72.27 / 72, "pc", 12, "mm", 72 / 25.4, "cm", 72 / 2.54, "\\hsize", 100, "\\vsize", 100, "\\textwidth", 100, "\\textheight", 100, "\\pagewidth", 100, "\\linewidth", 100 ); support: - contents: "my $a_box = [ [ $a11, $a12, $a13, $a14, $a15, $a16 ], \n[ $a21, $a22, $a23, $a24, $a25, $a26 ], [ $a31, $a32, $a33, $a34, $a35, $a36 ],\n[ $a41, $a42, $a43, $a44, $a45, $a46 ], [ $a51, $a52, $a53, $a54, $a55, $a56 ],\n\t[ $a61, $a62, $a63, $a64, $a65, $a66 ], ];\n" extension: name: A matrix restyled: | my $a_box = [ [ $a11, $a12, $a13, $a14, $a15, $a16 ], [ $a21, $a22, $a23, $a24, $a25, $a26 ], [ $a31, $a32, $a33, $a34, $a35, $a36 ], [ $a41, $a42, $a43, $a44, $a45, $a46 ], [ $a51, $a52, $a53, $a54, $a55, $a56 ], [ $a61, $a62, $a63, $a64, $a65, $a66 ], ]; support: - contents: | %TV=(flintstones=>{series=>"flintstones",nights=>[qw(monday thursday friday)], members=>[{name=>"fred",role=>"lead",age=>36,},{name=>"wilma",role=>"wife", age=>31,},{name=>"pebbles",role=>"kid",age=>4,},],},jetsons=>{series=>"jetsons", nights=>[qw(wednesday saturday)],members=>[{name=>"george",role=>"lead",age=>41, },{name=>"jane",role=>"wife",age=>39,},{name=>"elroy",role=>"kid",age=>9,},],}, simpsons=>{series=>"simpsons",nights=>[qw(monday)],members=>[{name=>"homer", role=>"lead",age=>34,},{name=>"marge",role=>"wife",age=>37,},{name=>"bart", role=>"kid",age=>11,},],},); extension: name: A complex data structure restyled: | %TV = ( flintstones => { series => "flintstones", nights => [qw(monday thursday friday)], members => [ { name => "fred", role => "lead", age => 36, }, { name => "wilma", role => "wife", age => 31, }, { name => "pebbles", role => "kid", age => 4, }, ], }, jetsons => { series => "jetsons", nights => [qw(wednesday saturday)], members => [ { name => "george", role => "lead", age => 41, }, { name => "jane", role => "wife", age => 39, }, { name => "elroy", role => "kid", age => 9, }, ], }, simpsons => { series => "simpsons", nights => [qw(monday)], members => [ { name => "homer", role => "lead", age => 34, }, { name => "marge", role => "wife", age => 37, }, { name => "bart", role => "kid", age => 11, }, ], }, ); support: - contents: "{\n L9140:\n if ($msccom::obj==$msccom::food) {\n goto L8142;\n }\n if ($msccom::obj==$msccom::bird||$msccom::obj==$msccom::snake||$msccom::obj==$msccom::clam||$msccom::obj==$msccom::oyster||$msccom::obj==$msccom::dwarf||$msccom::obj==$msccom::dragon||$msccom::obj==$msccom::troll||$msccom::obj==$msccom::bear) {\n $msccom::spk=71;\n }\n goto L2011;\n # \n # DRINK. IF NO OBJECT, ASSUME WATER AND LOOK FOR IT HERE. IF WATER IS \n # THE BOTTLE, DRINK THAT, ELSE MUST BE AT A WATER LOC, SO DRINK STREAM. \n # \n L9150:\n if ($msccom::obj==0&&$liqloc->($placom::loc)!=$msccom::water&&($liq->(0)!=$msccom::water||!$here->($msccom::bottle))) {\n goto L8000;\n }\n if ($msccom::obj!=0&&$msccom::obj!=$msccom::water) {\n $msccom::spk=110;\n }\n if ($msccom::spk==110||$liq->(0)!=$msccom::water||!$here->($msccom::bottle)) {\n goto L2011;\n }\n $placom::prop->($msccom::bottle)=1;\n $placom::place->($msccom::water)=0;\n $msccom::spk=74;\n goto L2011;\n # \n # RUB. YIELDS VARIOUS SNIDE REMARKS. \n # \n L9160:\n if ($msccom::obj!=$placom::lamp) {\n $msccom::spk=76;\n }\n goto L2011;\n # \n # THROW. SAME AS DISCARD UNLESS AXE. THEN SAME AS ATTACK EXCEPT IGNOR \n # AND IF DWARF IS PRESENT THEN ONE MIGHT BE KILLED. \ (ONLY WAY TO DO SO \n # AXE ALSO SPECIAL FOR DRAGON, BEAR, AND TROLL. \ TREASURES SPECIAL FOR \n # \n L9170:\n if ($toting->($msccom::rod2)&&$msccom::obj==$msccom::rod&&!$toting->($msccom::rod)) {\n $msccom::obj=$msccom::rod2;\n }\n }\n" extension: name: Cleaning up code from a code generator restyled: | { L9140: if ( $msccom::obj == $msccom::food ) { goto L8142; } if ( $msccom::obj == $msccom::bird || $msccom::obj == $msccom::snake || $msccom::obj == $msccom::clam || $msccom::obj == $msccom::oyster || $msccom::obj == $msccom::dwarf || $msccom::obj == $msccom::dragon || $msccom::obj == $msccom::troll || $msccom::obj == $msccom::bear ) { $msccom::spk = 71; } goto L2011; # # DRINK. IF NO OBJECT, ASSUME WATER AND LOOK FOR IT HERE. IF WATER IS # THE BOTTLE, DRINK THAT, ELSE MUST BE AT A WATER LOC, SO DRINK STREAM. # L9150: if ( $msccom::obj == 0 && $liqloc->($placom::loc) != $msccom::water && ( $liq->(0) != $msccom::water || !$here->($msccom::bottle) ) ) { goto L8000; } if ( $msccom::obj != 0 && $msccom::obj != $msccom::water ) { $msccom::spk = 110; } if ( $msccom::spk == 110 || $liq->(0) != $msccom::water || !$here->($msccom::bottle) ) { goto L2011; } $placom::prop->($msccom::bottle) = 1; $placom::place->($msccom::water) = 0; $msccom::spk = 74; goto L2011; # # RUB. YIELDS VARIOUS SNIDE REMARKS. # L9160: if ( $msccom::obj != $placom::lamp ) { $msccom::spk = 76; } goto L2011; # # THROW. SAME AS DISCARD UNLESS AXE. THEN SAME AS ATTACK EXCEPT IGNOR # AND IF DWARF IS PRESENT THEN ONE MIGHT BE KILLED. (ONLY WAY TO DO SO # AXE ALSO SPECIAL FOR DRAGON, BEAR, AND TROLL. TREASURES SPECIAL FOR # L9170: if ( $toting->($msccom::rod2) && $msccom::obj == $msccom::rod && !$toting->($msccom::rod) ) { $msccom::obj = $msccom::rod2; } } support: name: perltidy run_as_filter: true supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - pg_format - "--inplace" documentation: - https://github.com/darold/pgFormatter#readme enabled: true image: restyled/restyler-pg_format:v5.3 include: - "**/*.sql" interpreters: [] metadata: languages: - PSQL tests: - contents: | SELECT * from students WHERE students.age > 10; extension: name: restyled: |+ SELECT * FROM students WHERE students.age > 10; support: name: pg_format run_as_filter: false supports_arg_sep: false supports_multiple_paths: false - arguments: [] command: - php-cs-fixer - fix documentation: - https://github.com/FriendsOfPHP/PHP-CS-Fixer enabled: true image: restyled/restyler-php-cs-fixer:v3.64.0 include: - "**/*.php" interpreters: [] metadata: languages: - PHP tests: - contents: | foo(); extension: name: restyled: | foo(); support: name: php-cs-fixer run_as_filter: false supports_arg_sep: true supports_multiple_paths: false - arguments: [] command: - prettier-with-tailwindcss - "--write" documentation: - https://github.com/restyled-io/restyled.io/wiki/Common-Errors:-Prettier - https://prettier.io/docs/en/ enabled: true image: restyled/restyler-prettier:v3.3.3-2 include: - "**/*.js" - "**/*.jsx" interpreters: [] metadata: languages: - JavaScript tests: - contents: | matrix( 1, 0, 0, 0, 1, 0, 0, 0, 1 ) extension: js name: Matrix example restyled: 'matrix(1, 0, 0, 0, 1, 0, 0, 0, 1); ' support: - contents: | matrix( 1, 0, 0, 0, 1, 0, 0, 0, 1 ) extension: js name: With tailwindcss config restyled: 'matrix(1, 0, 0, 0, 1, 0, 0, 0, 1); ' support: contents: | const defaultTheme = require('tailwindcss/defaultTheme') module.exports = { ...defaultTheme, } path: tailwind.config.js name: prettier run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - prettier-with-tailwindcss - "--write" documentation: - https://prettier.io/docs/en/options.html#parser enabled: true image: restyled/restyler-prettier:v3.3.3-2 include: - "**/*.json" interpreters: [] metadata: languages: - JSON tests: - contents: | { "foo": "bar" , "baz": "bat" } extension: json name: restyled: | { "foo": "bar", "baz": "bat" } support: name: prettier-json run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - prettier-with-tailwindcss - "--write" documentation: - https://prettier.io/blog/2017/11/07/1.8.0.html - https://prettier.io/docs/en/index.html enabled: true image: restyled/restyler-prettier:v3.3.3-2 include: - "**/*.md" - "**/*.markdown" interpreters: [] metadata: languages: - Markdown tests: - contents: 'Voilà! In view, a humble vaudevillian veteran cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valourous visitation of a bygone vexation stands vivified and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition! The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it''s my very good honour to meet you and you may call me V. ' extension: md name: restyled: | Voilà! In view, a humble vaudevillian veteran cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valourous visitation of a bygone vexation stands vivified and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition! The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honour to meet you and you may call me V. support: contents: 'proseWrap: always ' path: ".prettierrc" name: prettier-markdown run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - prettier-with-tailwindcss - "--write" documentation: - https://prettier.io/docs/en/ - https://prettier.io/blog/2018/07/29/1.14.0.html enabled: true image: restyled/restyler-prettier:v3.3.3-2 include: - "**/*.yml" - "**/*.yaml" interpreters: [] metadata: languages: - Yaml tests: - contents: | foo: bar baz: bat extension: yaml name: restyled: | foo: bar baz: bat support: name: prettier-yaml run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - rbprettier - "--write" documentation: - https://prettier.io/docs/en/ - https://github.com/prettier/plugin-ruby enabled: false image: restyled/restyler-prettier-ruby:v3.2.2-1 include: - "**/*.rb" interpreters: - ruby metadata: languages: - Ruby tests: - contents: |2 d=[30644250780,9003106878, 30636278846,66641217692,4501790980, 671_24_603036,131_61973916,66_606629_920, 30642677916,30643069058];a,s=[],$*[0] s.each_byte{|b|a<<("%036b"%d[b. chr.to_i]).scan(/\d{6}/)} a.transpose.each{ |a| a.join.each_byte{\ |i|print i==49?\ ($*[1]||"#")\ :32.chr} puts } extension: rb name: restyled: | d = [ 30_644_250_780, 9_003_106_878, 30_636_278_846, 66_641_217_692, 4_501_790_980, 671_24_603036, 131_61973916, 66_606629_920, 30_642_677_916, 30_643_069_058 ] a, s = [], $*[0] s.each_byte { |b| a << ("%036b" % d[b.chr.to_i]).scan(/\d{6}/) } a.transpose.each do |a| a.join.each_byte { |i| print i == 49 ? ($*[1] || "#") : 32.chr } puts end support: name: prettier-ruby run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - purty - "--write" documentation: - https://github.com/joneshf/purty#readme enabled: true image: restyled/restyler-purty:v7.0.0 include: - "**/*.purs" interpreters: [] metadata: languages: - PureScript tests: - contents: | module Ado where foo = ado let w = 0 x <- pure 1 y <- do pure 2 pure 2 z <- do pure 3 in w + x + y + z bar = ado in 12 extension: name: Ado restyled: | module Ado where foo = ado let w = 0 x <- pure 1 y <- do pure 2 pure 2 z <- do pure 3 in w + x + y + z bar = ado in 12 support: name: purty run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - pyment - "-w" documentation: - https://github.com/dadadel/pyment enabled: true image: restyled/restyler-pyment:v0.3.3 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | def func(param1=True, param2: str = 'default val'): '''Description of func with docstring groups style. Params: param1 - descr of param1 that has True for default value. param2 - descr of param2 Returns: some value Raises: keyError: raises key exception TypeError: raises type exception ''' pass class A: def method(self, param1, param2=None) -> int: pass extension: name: restyled: "def func(param1=True, param2: str = 'default val'):\n \"\"\"Description of func with docstring groups style.\n\n :param param1: descr of param1 that has True for default value\n :param param2: descr of param2\n :param param2: str: (Default value = 'default val')\n :returns: some value\n \ :raises keyError: raises key exception\n :raises TypeError: raises type exception\n\n \"\"\"\n pass\n\nclass A:\n \"\"\" \"\"\"\n def method(self, param1, param2=None) -> int:\n \"\"\"\n\n :param param1: \n :param param2: (Default value = None)\n\n \"\"\"\n \ pass\n" support: - contents: | def func(param1=True, param2: str = 'default val'): '''Description of func with docstring groups style. Params: param1 - descr of param1 that has True for default value. param2 - descr of param2 Returns: some value Raises: keyError: raises key exception TypeError: raises type exception ''' pass class A: def method(self, param1, param2=None) -> int: pass extension: name: restyled: "def func(param1=True, param2: str = 'default val'):\n \"\"\"Description of func with docstring groups style.\n\n :param param1: descr of param1 that has True for default value\n :param param2: descr of param2\n :param param2: str: (Default value = 'default val')\n :returns: some value\n \ :raises keyError: raises key exception\n :raises TypeError: raises type exception\n\n \"\"\"\n pass\n\nclass A:\n \"\"\" \"\"\"\n def method(self, param1, param2=None) -> int:\n \"\"\"\n\n :param param1: \n :param param2: (Default value = None)\n\n \"\"\"\n \ pass\n" support: name: pyment run_as_filter: false supports_arg_sep: true supports_multiple_paths: false - arguments: [] command: - refmt - "--in-place" documentation: - https://github.com/reasonml/reason-cli#reason-cli enabled: true image: restyled/restyler-refmt:v3.3.3 include: - "**/*.re" interpreters: [] metadata: languages: - Reason tests: - contents: | type schoolPerson = Teacher | Director | Student(string); let greeting = person => switch (person){ | Teacher => "Hey Professor!" | Director => "Hello Director." | Student("Richard") => "Still here Ricky?" | Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "." }; extension: name: restyled: | type schoolPerson = | Teacher | Director | Student(string); let greeting = person => switch (person) { | Teacher => "Hey Professor!" | Director => "Hello Director." | Student("Richard") => "Still here Ricky?" | Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "." }; support: name: refmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - reorder-python-imports - "--exit-zero-even-if-changed" documentation: - https://github.com/asottile/reorder_python_imports enabled: true image: restyled/restyler-reorder-python-imports:v3.13.0 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | import os, sys from argparse import ArgumentParser from foo import bar from baz import womp from crazy import example1 extension: name: restyled: | import os import sys from argparse import ArgumentParser from baz import womp from crazy import example1 from foo import bar support: name: reorder-python-imports run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - rubocop - "--auto-correct" - "--fail-level" - fatal documentation: - https://rubocop.readthedocs.io/en/latest/ enabled: false image: restyled/restyler-rubocop:v1.66.0 include: - "**/*.rb" interpreters: - ruby metadata: languages: - Ruby tests: - contents: | def some_method do_something end extension: rb name: restyled: | def some_method do_something end support: - contents: | case foo when *[1, 2, 3, 4] bar when 5 baz end extension: rb name: restyled: | case foo when 1, 2, 3, 4 bar when 5 baz end support: - contents: | class User < ApplicationRecord MissingAdminAccount = Class.new(RuntimeError) include Wisper::Publisher # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable has_many :radars, foreign_key: "owner_id", dependent: :destroy has_many :created_topics, foreign_key: "creator_id", class_name: "Topic", dependent: :nullify has_many :blips, through: :radars attr_accessor :login validates :name, presence: true validates :username, presence: true, uniqueness: { case_sensitive: false } # For Devise def self.find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup if (login = conditions.delete(:login)) where(conditions).find_by(["lower(username) = :value OR lower(email) = :value", { value: login.downcase }]) else # :nocov: find_by(conditions) # :nocov: end end # Override Devise to use ActiveJob # https://github.com/plataformatec/devise#activejob-integration def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later end def find_radar(uuid:) radars.find_by!(uuid: uuid) end def new_radar(params) radars.new(params) end def add_radar(params) new_radar(params).tap(&:save!) end def first_sign_in? sign_in_count == 1 end after_create do |user| publish(:user_created, user) end def self.admin admin = find_by(admin: true) admin || raise(MissingAdminAccount) end end extension: rb name: restyled: | class User < ApplicationRecord MissingAdminAccount = Class.new(RuntimeError) include Wisper::Publisher # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable has_many :radars, foreign_key: 'owner_id', dependent: :destroy has_many :created_topics, foreign_key: 'creator_id', class_name: 'Topic', dependent: :nullify has_many :blips, through: :radars attr_accessor :login validates :name, presence: true validates :username, presence: true, uniqueness: { case_sensitive: false } # For Devise def self.find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup if (login = conditions.delete(:login)) where(conditions).find_by(['lower(username) = :value OR lower(email) = :value', { value: login.downcase }]) else # :nocov: find_by(conditions) # :nocov: end end # Override Devise to use ActiveJob # https://github.com/plataformatec/devise#activejob-integration def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later end def find_radar(uuid:) radars.find_by!(uuid: uuid) end def new_radar(params) radars.new(params) end def add_radar(params) new_radar(params).tap(&:save!) end def first_sign_in? sign_in_count == 1 end after_create do |user| publish(:user_created, user) end def self.admin admin = find_by(admin: true) admin || raise(MissingAdminAccount) end end support: name: rubocop run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - rustfmt documentation: - https://github.com/rust-lang-nursery/rustfmt#readme - https://github.com/restyled-io/restyled.io/wiki/Common-Errors:-Rustfmt enabled: true image: restyled/restyler-rustfmt:v1.7.0-stable include: - "**/*.rs" interpreters: [] metadata: languages: - Rust tests: - contents: | // Attributes should be on their own lines struct CRepr { x: f32,y: f32, } extension: name: restyled: | // Attributes should be on their own lines struct CRepr { x: f32, y: f32, } support: contents: 'nightly-2019-12-20 ' path: rust-toolchain name: rustfmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - scalafmt - "--non-interactive" documentation: - https://github.com/restyled-io/restyled.io/wiki/Common-Errors:-Scalafmt - https://scalameta.org/scalafmt/ enabled: false image: restyled/restyler-scalafmt:v3.7.10 include: - "**/*.scala" interpreters: [] metadata: languages: - Scala tests: - contents: | object a { def c(b: List[Int]): List[Int] = for { a <- b if ((a)) } yield a } extension: name: restyled: | object a { def c(b: List[Int]): List[Int] = for { a <- b if a } yield a } support: contents: | version = 3.7.10 runner.dialect = scala211 rewrite.rules = [RedundantParens] path: ".scalafmt.conf" name: scalafmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - shellcheck-fix documentation: - https://github.com/koalaman/shellcheck/wiki enabled: true image: restyled/restyler-shellcheck:v0.9.0 include: - "**/*.sh" - "**/*.bash" interpreters: - sh - bash metadata: languages: - POSIX sh - Bash tests: - contents: 'echo $foo ' extension: name: Simple un-quoted restyled: 'echo "$foo" ' support: - contents: | ## Example of a broken script. for f in $(ls *.m3u) do grep -qi hq.*mp3 $f \ && echo -e 'Playlist $f contains a HQ file in mp3 format' done extension: name: Man-page example restyled: | ## Example of a broken script. for f in $(ls *.m3u) do grep -qi hq.*mp3 "$f" \ && echo -e 'Playlist $f contains a HQ file in mp3 format' done support: - contents: | if (( $n > 1 )); then echo yeah fi extension: name: Non auto-fix issue restyled: | if (( $n > 1 )); then echo yeah fi support: - contents: 'echo "$foo" ' extension: name: Empty patch restyled: 'echo "$foo" ' support: name: shellcheck run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - shellharden - "--replace" documentation: - https://github.com/anordal/shellharden#readme enabled: true image: restyled/restyler-shellharden:v4.1.1-3 include: - "**/*.sh" - "**/*.bash" interpreters: - sh - bash metadata: languages: - POSIX sh - Bash tests: - contents: | #!/bin/sh x=x var=`echo $x` extension: name: restyled: | #!/bin/sh x=x var=`echo "$x"` support: name: shellharden run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: - "-i" - '2' - "-ci" command: - shfmt - "-w" documentation: - https://github.com/mvdan/sh#shfmt enabled: true image: restyled/restyler-shfmt:v3.4.3 include: - "**/*.sh" - "**/*.bash" interpreters: - sh - bash metadata: languages: - POSIX sh - Bash tests: - contents: | #!/bin/sh if [ 2 -eq 2 ] then echo "yup" fi extension: name: restyled: | #!/bin/sh if [ 2 -eq 2 ]; then echo "yup" fi support: name: shfmt run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - sqlformat - "--reindent" - "--keywords=upper" documentation: - https://github.com/andialbrecht/sqlparse#readme enabled: false image: restyled/restyler-sqlformat:0.5.1 include: - "**/*.sql" interpreters: [] metadata: languages: - SQL - PSQL tests: - contents: | -- hi there select * from students WHERE students.age > 10; extension: name: restyled: | -- hi there SELECT * FROM students WHERE students.age > 10; support: - contents: | INSERT INTO x VALUES () extension: name: restyled: | INSERT INTO x VALUES () support: name: sqlformat run_as_filter: true supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - standardrb - "--fix" documentation: - https://github.com/testdouble/standard enabled: true image: restyled/restyler-standardrb:v1.40.0 include: - "**/*.rb" interpreters: - ruby metadata: languages: - Ruby tests: - contents: | def some_method do_something end extension: rb name: restyled: | def some_method do_something end support: name: standardrb run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - stylish-haskell - "--inplace" documentation: - https://github.com/jaspervdj/stylish-haskell - https://github.com/restyled-io/restyled.io/wiki/Common-Errors-Stylish-Haskell enabled: true image: restyled/restyler-stylish-haskell:v0.14.3.0 include: - "**/*.hs" interpreters: [] metadata: languages: - Haskell tests: - contents: | {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} extension: name: restyled: | {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} support: - contents: | {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Restyler.App ( -- * Application environment App(..) , AppT , runAppT -- * Application errors , AppError(..) , mapAppError ) where import Restyler.Prelude import Conduit (runResourceT, sinkFile) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Vector as V import GitHub.Endpoints.Issues.Comments import GitHub.Endpoints.PullRequests import GitHub.Endpoints.Repos.Statuses import GitHub.Request import Network.HTTP.Client.TLS import Network.HTTP.Simple hiding (Request) import Restyler.Capabilities.Docker import Restyler.Capabilities.Git import Restyler.Capabilities.GitHub import Restyler.Capabilities.RemoteFile import Restyler.Capabilities.System import Restyler.Model.Config import Restyler.Model.RemoteFile import qualified System.Directory as Directory import qualified System.Exit as Exit import System.Process -- | Application environment data App = App { appLogLevel :: LogLevel , appLogColor :: Bool , appAccessToken :: Text , appPullRequest :: PullRequest -- ^ The @'PullRequest'@ we are restyling , appConfig :: Config -- ^ Configuration loaded from @.restyled.yaml@ , appRestyledPullRequest :: Maybe SimplePullRequest -- ^ Existing restyled @'PullRequest'@ if it exists } -- | All possible application error conditions data AppError = PullRequestFetchError Error -- ^ We couldn't fetch the @'PullRequest'@ to restyle | PullRequestCloneError IOException -- ^ We couldn't clone or checkout the PR's branch | ConfigurationError String -- ^ We couldn't load a @.restyled.yaml@ | DockerError IOException -- ^ Error running a @docker@ operation | GitError IOException -- ^ Error running a @git@ operation | GitHubError Error -- ^ We encountered a GitHub API error during restyling | SystemError IOException -- ^ Trouble reading a file or etc | RemoteFileError IOException -- ^ Trouble performing some HTTP request | OtherError IOException -- ^ A minor escape hatch for @'IOException'@s deriving Show -- | Run a computation, and modify any thrown @'AppError'@s mapAppError :: MonadError AppError m => (AppError -> AppError) -> m a -> m a mapAppError f = (`catchError` throwError . f) newtype AppT m a = AppT { runAppT :: ReaderT App (LoggingT (ExceptT AppError m)) a } deriving ( Functor , Applicative , Monad , MonadError AppError , MonadReader App , MonadLogger ) -- | Run an @'IO'@ computation and capture @'IOException'@s to the given type appIO :: MonadIO m => (IOException -> AppError) -> IO a -> AppT m a appIO err f = AppT $ do result <- liftIO $ tryIO f either (throwError . err) pure result instance MonadIO m => MonadGit (AppT m) where cloneRepository url dir = do logDebugN $ "git clone " <> tshow [masked, dir] appIO GitError $ callProcess "git" ["clone", unpack url, dir] where masked = T.unpack $ scheme <> "://" <> T.dropWhile (/= '@') rest (scheme, rest) = T.breakOn "://" url checkoutBranch b branch = do logDebugN $ "git checkout " <> branch appIO GitError $ callProcess "git" $ ["checkout"] ++ [ "-b" | b ] ++ [unpack branch] changedPaths branch = do logDebugN $ "git diff --name-only " <> branch appIO GitError $ lines <$> readProcess "git" ["diff", "--name-only", unpack branch] "" commitAll msg = do logDebugN "git commit" appIO GitError $ callProcess "git" ["commit", "-am", unpack msg] fetchOrigin remoteRef localRef = do logDebugN $ "git fetch origin " <> remoteRef <> ":" <> localRef appIO GitError $ callProcess "git" ["fetch", "origin", unpack $ remoteRef <> ":" <> localRef] pushOrigin branch = do logDebugN $ "git push origin " <> branch appIO GitError $ callProcess "git" ["push", "origin", unpack branch] forcePushOrigin branch = do logDebugN $ "git push origin " <> branch appIO GitError $ callProcess "git" ["push", "--force-with-lease", "origin", unpack branch] instance MonadIO m => MonadGitHub (AppT m) where getPullRequest owner name num = runGitHub $ pullRequestR owner name num findPullRequest owner name base head = do results <- runGitHub $ pullRequestsForR owner name (optionsBase base <> optionsHead head) FetchAll pure $ results V.!? 0 createPullRequest owner name create = runGitHub $ createPullRequestR owner name create updatePullRequest owner name id' edit = runGitHub $ updatePullRequestR owner name id' edit getComments owner name id' = runGitHub $ commentsR owner name id' FetchAll createComment owner name id' body = runGitHub_ $ createCommentR owner name id' body deleteComment owner name id' = runGitHub_ $ deleteCommentR owner name id' createStatus owner name sha status = runGitHub_ $ createStatusR owner name sha status instance MonadIO m => MonadSystem (AppT m) where getCurrentDirectory = do logDebugN "getCurrentDirectory" appIO SystemError Directory.getCurrentDirectory doesFileExist path = do logDebugN $ "doesFileExist: " <> tshow path appIO SystemError $ Directory.doesFileExist path setCurrentDirectory path = do logDebugN $ "setCurrentDirectory: " <> tshow path appIO SystemError $ Directory.setCurrentDirectory path readFile path = do logDebugN $ "readFile: " <> tshow path appIO SystemError $ T.readFile path exitSuccess = appIO SystemError Exit.exitSuccess instance MonadIO m => MonadDocker (AppT m) where dockerRun args = do logDebugN $ "docker run " <> tshow args appIO DockerError $ callProcess "docker" $ "run" : args instance MonadIO m => MonadRemoteFile (AppT m) where fetchRemoteFile RemoteFile{..} = do let url = getUrl rfUrl logInfoN $ "Fetching " <> tshow rfPath <> " from " <> tshow url appIO RemoteFileError $ do request <- parseRequest $ unpack url runResourceT $ httpSink request $ \_ -> sinkFile rfPath -- | Run a GitHub @'Request'@ runGitHub :: MonadIO m => Request k a -> AppT m a runGitHub req = do logDebugN $ "GitHub request: " <> showGitHubRequest req auth <- asks $ OAuth . encodeUtf8 . appAccessToken result <- appIO OtherError $ do mgr <- getGlobalManager executeRequestWithMgr mgr auth req either (throwError . GitHubError) pure result -- | @'runGitHub'@ but discard the result runGitHub_ :: MonadIO m => Request k a -> AppT m () runGitHub_ = void . runGitHub -- | Show a GitHub @'Request'@, useful for debugging -- brittany-disable-next-binding showGitHubRequest :: Request k a -> Text showGitHubRequest (SimpleQuery (Query ps qs)) = mconcat [ "[GET] " , "/" <> T.intercalate "/" ps , "?" <> T.intercalate "&" (queryParts qs) ] showGitHubRequest (SimpleQuery (PagedQuery ps qs fc)) = mconcat [ "[GET] " , "/" <> T.intercalate "/" ps , "?" <> T.intercalate "&" (queryParts qs) , " (" <> tshow fc <> ")" ] showGitHubRequest (SimpleQuery (Command m ps _body)) = mconcat [ "[" <> T.toUpper (tshow m) <> "] " , "/" <> T.intercalate "/" ps ] showGitHubRequest (StatusQuery _ _) = "" showGitHubRequest (HeaderQuery _ _) = "
" showGitHubRequest (RedirectQuery _) = "" queryParts :: QueryString -> [Text] queryParts = map $ \(k, mv) -> decodeUtf8 k <> "=" <> maybe "" decodeUtf8 mv extension: name: restyled: | {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Restyler.App ( -- * Application environment App(..) , AppT , runAppT -- * Application errors , AppError(..) , mapAppError ) where import Restyler.Prelude import Conduit (runResourceT, sinkFile) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Vector as V import GitHub.Endpoints.Issues.Comments import GitHub.Endpoints.PullRequests import GitHub.Endpoints.Repos.Statuses import GitHub.Request import Network.HTTP.Client.TLS import Network.HTTP.Simple hiding (Request) import Restyler.Capabilities.Docker import Restyler.Capabilities.Git import Restyler.Capabilities.GitHub import Restyler.Capabilities.RemoteFile import Restyler.Capabilities.System import Restyler.Model.Config import Restyler.Model.RemoteFile import qualified System.Directory as Directory import qualified System.Exit as Exit import System.Process -- | Application environment data App = App { appLogLevel :: LogLevel , appLogColor :: Bool , appAccessToken :: Text , appPullRequest :: PullRequest -- ^ The @'PullRequest'@ we are restyling , appConfig :: Config -- ^ Configuration loaded from @.restyled.yaml@ , appRestyledPullRequest :: Maybe SimplePullRequest -- ^ Existing restyled @'PullRequest'@ if it exists } -- | All possible application error conditions data AppError = PullRequestFetchError Error -- ^ We couldn't fetch the @'PullRequest'@ to restyle | PullRequestCloneError IOException -- ^ We couldn't clone or checkout the PR's branch | ConfigurationError String -- ^ We couldn't load a @.restyled.yaml@ | DockerError IOException -- ^ Error running a @docker@ operation | GitError IOException -- ^ Error running a @git@ operation | GitHubError Error -- ^ We encountered a GitHub API error during restyling | SystemError IOException -- ^ Trouble reading a file or etc | RemoteFileError IOException -- ^ Trouble performing some HTTP request | OtherError IOException -- ^ A minor escape hatch for @'IOException'@s deriving Show -- | Run a computation, and modify any thrown @'AppError'@s mapAppError :: MonadError AppError m => (AppError -> AppError) -> m a -> m a mapAppError f = (`catchError` throwError . f) newtype AppT m a = AppT { runAppT :: ReaderT App (LoggingT (ExceptT AppError m)) a } deriving ( Functor , Applicative , Monad , MonadError AppError , MonadReader App , MonadLogger ) -- | Run an @'IO'@ computation and capture @'IOException'@s to the given type appIO :: MonadIO m => (IOException -> AppError) -> IO a -> AppT m a appIO err f = AppT $ do result <- liftIO $ tryIO f either (throwError . err) pure result instance MonadIO m => MonadGit (AppT m) where cloneRepository url dir = do logDebugN $ "git clone " <> tshow [masked, dir] appIO GitError $ callProcess "git" ["clone", unpack url, dir] where masked = T.unpack $ scheme <> "://" <> T.dropWhile (/= '@') rest (scheme, rest) = T.breakOn "://" url checkoutBranch b branch = do logDebugN $ "git checkout " <> branch appIO GitError $ callProcess "git" $ ["checkout"] ++ [ "-b" | b ] ++ [unpack branch] changedPaths branch = do logDebugN $ "git diff --name-only " <> branch appIO GitError $ lines <$> readProcess "git" ["diff", "--name-only", unpack branch] "" commitAll msg = do logDebugN "git commit" appIO GitError $ callProcess "git" ["commit", "-am", unpack msg] fetchOrigin remoteRef localRef = do logDebugN $ "git fetch origin " <> remoteRef <> ":" <> localRef appIO GitError $ callProcess "git" ["fetch", "origin", unpack $ remoteRef <> ":" <> localRef] pushOrigin branch = do logDebugN $ "git push origin " <> branch appIO GitError $ callProcess "git" ["push", "origin", unpack branch] forcePushOrigin branch = do logDebugN $ "git push origin " <> branch appIO GitError $ callProcess "git" ["push", "--force-with-lease", "origin", unpack branch] instance MonadIO m => MonadGitHub (AppT m) where getPullRequest owner name num = runGitHub $ pullRequestR owner name num findPullRequest owner name base head = do results <- runGitHub $ pullRequestsForR owner name (optionsBase base <> optionsHead head) FetchAll pure $ results V.!? 0 createPullRequest owner name create = runGitHub $ createPullRequestR owner name create updatePullRequest owner name id' edit = runGitHub $ updatePullRequestR owner name id' edit getComments owner name id' = runGitHub $ commentsR owner name id' FetchAll createComment owner name id' body = runGitHub_ $ createCommentR owner name id' body deleteComment owner name id' = runGitHub_ $ deleteCommentR owner name id' createStatus owner name sha status = runGitHub_ $ createStatusR owner name sha status instance MonadIO m => MonadSystem (AppT m) where getCurrentDirectory = do logDebugN "getCurrentDirectory" appIO SystemError Directory.getCurrentDirectory doesFileExist path = do logDebugN $ "doesFileExist: " <> tshow path appIO SystemError $ Directory.doesFileExist path setCurrentDirectory path = do logDebugN $ "setCurrentDirectory: " <> tshow path appIO SystemError $ Directory.setCurrentDirectory path readFile path = do logDebugN $ "readFile: " <> tshow path appIO SystemError $ T.readFile path exitSuccess = appIO SystemError Exit.exitSuccess instance MonadIO m => MonadDocker (AppT m) where dockerRun args = do logDebugN $ "docker run " <> tshow args appIO DockerError $ callProcess "docker" $ "run" : args instance MonadIO m => MonadRemoteFile (AppT m) where fetchRemoteFile RemoteFile{..} = do let url = getUrl rfUrl logInfoN $ "Fetching " <> tshow rfPath <> " from " <> tshow url appIO RemoteFileError $ do request <- parseRequest $ unpack url runResourceT $ httpSink request $ \_ -> sinkFile rfPath -- | Run a GitHub @'Request'@ runGitHub :: MonadIO m => Request k a -> AppT m a runGitHub req = do logDebugN $ "GitHub request: " <> showGitHubRequest req auth <- asks $ OAuth . encodeUtf8 . appAccessToken result <- appIO OtherError $ do mgr <- getGlobalManager executeRequestWithMgr mgr auth req either (throwError . GitHubError) pure result -- | @'runGitHub'@ but discard the result runGitHub_ :: MonadIO m => Request k a -> AppT m () runGitHub_ = void . runGitHub -- | Show a GitHub @'Request'@, useful for debugging -- brittany-disable-next-binding showGitHubRequest :: Request k a -> Text showGitHubRequest (SimpleQuery (Query ps qs)) = mconcat [ "[GET] " , "/" <> T.intercalate "/" ps , "?" <> T.intercalate "&" (queryParts qs) ] showGitHubRequest (SimpleQuery (PagedQuery ps qs fc)) = mconcat [ "[GET] " , "/" <> T.intercalate "/" ps , "?" <> T.intercalate "&" (queryParts qs) , " (" <> tshow fc <> ")" ] showGitHubRequest (SimpleQuery (Command m ps _body)) = mconcat [ "[" <> T.toUpper (tshow m) <> "] " , "/" <> T.intercalate "/" ps ] showGitHubRequest (StatusQuery _ _) = "" showGitHubRequest (HeaderQuery _ _) = "
" showGitHubRequest (RedirectQuery _) = "" queryParts :: QueryString -> [Text] queryParts = map $ \(k, mv) -> decodeUtf8 k <> "=" <> maybe "" decodeUtf8 mv support: - contents: | module Foo where import FrontRow.Renaissance.RenaissancePlatform import FrontRow.Renaissance.RPID import FrontRow.Renaissance.RPIdentifier extension: name: restyled: | module Foo where import FrontRow.Renaissance.RenaissancePlatform import FrontRow.Renaissance.RPID import FrontRow.Renaissance.RPIdentifier support: name: stylish-haskell run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - taplo - fmt documentation: - https://taplo.tamasfe.dev/cli/usage/formatting.html enabled: true image: restyled/restyler-taplo:0.9.3 include: - "**/*.toml" interpreters: [] metadata: languages: - TOML tests: - contents: | var = true list = [ 'hi', 'there' , 'now' ] extension: name: restyled: | var = true list = ['hi', 'there', 'now'] support: - contents: | long_list = [ 'hi', 'there' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' , 'now' ] extension: name: restyled: | long_list = [ 'hi', 'there', 'now', 'now', 'now', 'now', 'now', 'now', 'now', 'now', 'now', 'now', 'now', 'now', ] support: name: taplo run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - terraform - fmt documentation: - https://www.terraform.io/docs/commands/fmt.html enabled: true image: restyled/restyler-terraform:v0.12.24-2 include: - "**/*.tf" interpreters: [] metadata: languages: - Terraform tests: - contents: | locals = { short = 1 this_is_longer = true this_is_really_longer_than_it_needs_to_be = "bazzle" } extension: tf name: restyled: | locals = { short = 1 this_is_longer = true this_is_really_longer_than_it_needs_to_be = "bazzle" } support: - contents: | variable "policy_definition_name" { description = "Policy definition name must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and is limited between 2 and 60 characters in length." default = "demoPolicy" } extension: tf name: restyled: | variable "policy_definition_name" { description = "Policy definition name must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and is limited between 2 and 60 characters in length." default = "demoPolicy" } support: name: terraform run_as_filter: false supports_arg_sep: true supports_multiple_paths: false - arguments: [] command: - verible-verilog-format - "--inplace" documentation: - https://google.github.io/verible/verilog_format.html enabled: true image: restyled/restyler-verible:v0.0-1318-gf6b4485 include: - "**/*.sv" interpreters: [] metadata: languages: - System Verilog tests: - contents: | module debounce( input wire logic clk, output logic debounced ); stateType ns; always_comb begin ns = ERR; end logic timerDone; logic clrTimer; endmodule extension: name: restyled: | module debounce ( input wire logic clk, output logic debounced ); stateType ns; always_comb begin ns = ERR; end logic timerDone; logic clrTimer; endmodule support: name: verible run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - whitespace documentation: - https://github.com/restyled-io/restyler-whitespace/blob/master/README.md enabled: true image: restyled/restyler-whitespace:v0.2.0.0 include: - "**/*" - "!**/*.gif" - "!**/*.ico" - "!**/*.jpeg" - "!**/*.jpg" - "!**/*.pdf" - "!**/*.png" - "!**/fonts/**/*" interpreters: [] metadata: languages: - "*" tests: - contents: "line one \nline two \n \nline three \\\nline four\n" extension: name: restyled: | line one line two line three \ line four support: - contents: |+ line one line two line three extension: name: restyled: | line one line two line three support: - contents: |- line one line two line three extension: name: restyled: | line one line two line three support: - contents: "line one\r\nline two\r\nline three\r\n" extension: name: restyled: "line one\r\nline two\r\nline three\r\n" support: name: whitespace run_as_filter: false supports_arg_sep: true supports_multiple_paths: true - arguments: [] command: - yapf - "--in-place" documentation: - https://github.com/google/yapf enabled: true image: restyled/restyler-yapf:v0.40.2-1 include: - "**/*.py" interpreters: - python metadata: languages: - Python tests: - contents: | import math, sys; def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple=( 1,2, 3,'a' ); some_variable={'long':'Long code lines should be wrapped within 79 characters.', 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, 20,300,40000,500000000,60000000000000000]}} return (some_tuple, some_variable) extension: name: restyled: | import math, sys def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple = (1, 2, 3, 'a') some_variable = { 'long': 'Long code lines should be wrapped within 79 characters.', 'other': [ math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on' ], 'more': { 'inner': 'This whole logical line should be wrapped.', some_tuple: [1, 20, 300, 40000, 500000000, 60000000000000000] } } return (some_tuple, some_variable) support: name: yapf run_as_filter: false supports_arg_sep: true supports_multiple_paths: true