Code Monkey home page Code Monkey logo

ghokin's Introduction

ghokin's People

Contributors

antham avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ghokin's Issues

Update module name to include version 3

Issue:
We want to use latest version of this module as part of toolchain, but the latest version is greater than v0 or v1 and the module name does not specify higher version.

How to reproduce:
execute go get github.com/antham/ghokin

Expected:

require (
	github.com/antham/ghokin/v3 v3.1.0
)

Actual:

require (
	github.com/antham/ghokin v1.7.0
)

Another option would be do release latest code under v1.8.0 and disregard updating major version in the future and stick to v1

I'd make a PR myself, but the repo doesn't have Makefile, I am too lazy to launch it myself.

Dependabot can't parse your go.mod

Dependabot couldn't parse the go.mod found at /go.mod.

The error Dependabot encountered was:

go: github.com/spf13/[email protected] requires
	github.com/grpc-ecosystem/[email protected] requires
	gopkg.in/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /opt/go/gopath/pkg/mod/cache/vcs/9241c28341fcedca6a799ab7a465dd6924dc5d94044cbfabb75778817250adfc: exit status 128:
	fatal: The remote end hung up unexpectedly

View the update logs.

Feature description is too much indented

The feature description is indented following indent.tableAndDocString option which seems strange.

Example of feature file from gherkin reference:

Feature: Multiple site support
  Only blog owners can post to a blog, except administrators,
  who can post to all blogs.

  Background:
    Given a global administrator named "Greg"

ghokin fmt stdout:

Feature: Multiple site support
      Only blog owners can post to a blog, except administrators,
      who can post to all blogs.

  Background:
    Given a global administrator named "Greg"

I would expect feature description to be indented as much as Background and Scenario.

I also suggest to drop separate configuration for indentation and use only a relative indent option:

indent:
  level: [0-9]+
  character: (space|tab)

Indeed, I am not sure someone will use an asymmetric indentation. However, it will be easier to handle formatting with new feature in gherkin syntax (like the new Rule keyword):

Feature: Highlander

  Rule: There can be only One

    Example: Only One -- More than one alive
      Given there are 3 ninjas

Also, thank you for this tool!

Formatting empty scenarios removes them

Thanks for the great formatter!
We faced one issue with removing empty scenarios. Unfortunately, I don't know Go so I can't make PR for this

Feature file:

Feature: A suite 1

Scenario: asdsad asdsad asdsad
  Given the user disconnects the water

Scenario: as 123 dsad
Scenario: adsad 
Scenario: asds asdsa ad

Result:

Feature: A suite 1

  Scenario: asdsad asdsad asdsad
    Given the user disconnects the water

  Scenario: as 123 dsad

Double backslash removed in table

Two backslashes in a table get turned into one. This is annoying as I decode the string and cannot use backslashes this way.
Also this means that running ghokin multiple times gives different results.

Example:

Feature: f
  Scenario: s
    Given a
      | name      |
      | hello\\\n |

gets formatted into:

Feature: f
  Scenario: s
    Given a
      | name     |
      | hello\\n |

which in turn gets formatted into

Feature: f
  Scenario: s
    Given a
      | name    |
      | hello\n |

Fails with "Rule" keyword

a feature file with the rule keyword deletes the content of the rule

Rule: Eligible participants must be counted

becomes

Rule

Comment indentation is incorrect for last scenario

When I add a comment after a scenario and format it with ghokin, normally it gets indented with 2 spaces (using default config).

But if I add a comment after the last scenario and format it with ghokin, it instead gets indented to the same level as whatever is above it. So if the previous line is a Then indented with 4 spaces, the comment is also indented with 4 spaces. If the previous line is a row in an Examples table indented with 6 spaces, the comment is also indented with 6 spaces.

Escaped pipe being formatted to invalid value

I've got a situation where I need to use a | in a table value. Godog accepts a \| as an escape sequence for the pipe, but Ghokin replaces it with |, breaking godog and cucumber.js:

Input:

Feature: Test

	Scenario: Pipe in table value
		Given I have a table:
			| a | b \| c |

Output:

Feature: Test

  Scenario: Pipe in table value
    Given I have a table:
      | a | b | c |

Expected:

Feature: Test

  Scenario: Pipe in table value
    Given I have a table:
      | a | b \| c |

Support files which starts with BOM unicode character

Issue
We are trying to format our feature files, but looks like it is not possible if it's encoded with e.g UTF-8 or Unicode.

Update
With further investigations, it turned out that the root of the problem is not the Encoding.
It seems the BOM character is the culprit in this case.

How to reproduce
With BOM
with-bom-character.zip

  1. ghokin.exe check with-bom-character.feature
  2. Fails with Parser error

Without BOM
without-bom-character.zip

  1. ghokin.exe check without-bom-character.feature
  2. Works fine

Unable to install from `go get`

$ go version
go version go1.14.9 darwin/amd64

$ go get -v github.com/antham/ghokin
github.com/spf13/cast (download)
github.com/spf13/jwalterweatherman (download)
github.com/subosito/gotenv (download)
get "gopkg.in/ini.v1": found meta tag get.metaImport{Prefix:"gopkg.in/ini.v1", VCS:"git", RepoRoot:"https://gopkg.in/ini.v1"} at //gopkg.in/ini.v1?go-get=1
gopkg.in/ini.v1 (download)
golang.org/x/sys/internal/unsafeheader
github.com/hashicorp/hcl/hcl/strconv
golang.org/x/text/transform
github.com/fatih/color/vendor/github.com/mattn/go-isatty
golang.org/x/sys/unix
github.com/spf13/afero/mem
github.com/mitchellh/go-homedir
github.com/spf13/jwalterweatherman
github.com/subosito/gotenv
gopkg.in/ini.v1
github.com/fatih/color/vendor/github.com/mattn/go-colorable
github.com/hashicorp/hcl/hcl/token
github.com/spf13/cast
github.com/gogo/protobuf/proto
golang.org/x/text/unicode/norm
github.com/pelletier/go-toml
github.com/gofrs/uuid
gopkg.in/yaml.v2
github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/json/token
github.com/hashicorp/hcl/hcl/ast
github.com/fatih/color
github.com/mitchellh/mapstructure
github.com/spf13/pflag
github.com/magiconair/properties
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/hcl/parser
github.com/hashicorp/hcl/json/parser
github.com/hashicorp/hcl/hcl/printer
github.com/spf13/afero
github.com/hashicorp/hcl
github.com/fsnotify/fsnotify
github.com/spf13/cobra
github.com/spf13/viper
github.com/gogo/protobuf/io
github.com/cucumber/messages-go
github.com/cucumber/gherkin-go
github.com/antham/ghokin/ghokin
# github.com/antham/ghokin/ghokin
../antham/ghokin/ghokin/transformer.go:41:3: undefined: gherkin.TokenType_FeatureLine
../antham/ghokin/ghokin/transformer.go:42:3: undefined: gherkin.TokenType_BackgroundLine
../antham/ghokin/ghokin/transformer.go:43:3: undefined: gherkin.TokenType_ScenarioLine
../antham/ghokin/ghokin/transformer.go:44:3: undefined: gherkin.TokenType_DocStringSeparator
../antham/ghokin/ghokin/transformer.go:45:3: undefined: gherkin.TokenType_RuleLine
../antham/ghokin/ghokin/transformer.go:46:3: undefined: gherkin.TokenType_StepLine
../antham/ghokin/ghokin/transformer.go:47:3: undefined: gherkin.TokenType_ExamplesLine
../antham/ghokin/ghokin/transformer.go:48:3: undefined: gherkin.TokenType_Other
../antham/ghokin/ghokin/transformer.go:49:3: undefined: gherkin.TokenType_TableRow
../antham/ghokin/ghokin/transformer.go:53:3: undefined: gherkin.TokenType_FeatureLine
../antham/ghokin/ghokin/transformer.go:53:3: too many errors

Keep newline characters

Is it possible to add a flag that would make the formatter not strip newline characters from the end of the file?

"\n" in table cell is replaced by an actual newline in the output

When you format a table that contains \n, fmt replaces it with an actual newline instead of outputting the characters \n again.
Failing testcase: sherter@d6f88c6

--- FAIL: TestTransform (0.00s)
    --- FAIL: TestTransform/fixtures/escape-newline.feature (0.00s)
        transformer_test.go:471:
                Error Trace:    /home/simon/repositories/ghokin/ghokin/transformer_test.go:471
                Error:          Not equal:
                                expected: "Feature: Test\n\n  Scenario: Newline in table value\n    Given I have a table:\n      | a | b \\n c | \\n d | \\n e \\n |\n      | f | g      | h    | i       |\n"
                                actual  : "Feature: Test\n\n  Scenario: Newline in table value\n    Given I have a table:\n      | a | b \n c | \n d | \n e \n |\n      | f | g     | h   | i     |\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -4,4 +4,8 @@
                                     Given I have a table:
                                -      | a | b \n c | \n d | \n e \n |
                                -      | f | g      | h    | i       |
                                +      | a | b
                                + c |
                                + d |
                                + e
                                + |
                                +      | f | g     | h   | i     |

                Test:           TestTransform/fixtures/escape-newline.feature
FAIL
exit status 1
FAIL    github.com/antham/ghokin/v3/ghokin      0.113s

According to https://cucumber.io/docs/gherkin/reference/#table-cell-escaping it's valid to use \n in table cells.

Accept folder when using stdout

It would be nice if fmt stdout would accept a directory like fmt replace does.

It would be an added bonus if there are any changes to be made the tool could exit with a non-zero exit code. This could then be checked when running other tests and fail a build if the files are not correctly formatted.

Showing what would change in the file if replace was being run instead would also be nice.

Come to think of it, maybe stdout should stay the same and another option called check could be introduced.

Let me know if you want me to open separate issues for each thing I mentioned.

Cheking files are well-formatted

Add a command to verify if file/folder are correctly formatted

  • could be name check and would take same parameters as replace
  • would throw an exit code 1, if files are not well formatted, 0 otherwise
  • would list all files not properly formatted

Dependabot can't parse your go.mod

Dependabot couldn't parse the go.mod found at /go.mod.

The error Dependabot encountered was:

go: github.com/spf13/[email protected] requires
	gopkg.in/[email protected] requires
	gopkg.in/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /opt/go/gopath/pkg/mod/cache/vcs/9241c28341fcedca6a799ab7a465dd6924dc5d94044cbfabb75778817250adfc: exit status 128:
	fatal: The remote end hung up unexpectedly

View the update logs.

Feature Request: Extra indentation of AND

Hey,
would it be possible to add a config parameter to add an extra indentation of AND?
e.g.:

SCENATRIO ...
    GIVEN ....
        AND ....
        AND ...
    WHEN ...
    THEN ....
        AND ....

Non-ASCII characters cause table column width to grow unnecessarily

See sherter@ea0fba4

For each non-ascii character in the table cell, the table column width grows one space larger than it needs to be.

    --- FAIL: TestTransform/fixtures/table-with-non-ascii-characters.feature (0.00s)
        transformer_test.go:475:
                Error Trace:    /home/simon/repositories/ghokin/ghokin/transformer_test.go:475
                Error:          Not equal:
                                expected: "Feature: A Feature\n  Description\n\n  Scenario: A scenario to test\n    Given a thing\n      | äöüûú |\n\n"
                                actual  : "Feature: A Feature\n  Description\n\n  Scenario: A scenario to test\n    Given a thing\n      | äöüûú      |\n\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -5,3 +5,3 @@
                                     Given a thing
                                -      | äöüûú |
                                +      | äöüûú      |

                Test:           TestTransform/fixtures/table-with-non-ascii-characters.feature

In this example we have 5 non-ascii characters and the column is 5 spaces larger than it needs to be.

Can this work from stdin?

Would be much easier to use as a plugin and formatter inside of vim if ghokin could take content from stdin.

Description formatting options

I would suggest a max-line-length: 80 option for description. to break long line in multiple lines.

Another idea would be to also add a space-before-description: true.

With the two options, the file:

Feature: Multiple site support
  Only blog owners can post to a blog, except administrators, who can post to all blogs.

  Scenario: Dr. Bill tries to post to somebody else's blog, and fails
    Given I am logged in as Dr. Bill

would be formatted:

Feature: Multiple site support

  Only blog owners can post to a blog, except administrators, who can post to
  all blogs.

  Scenario: Dr. Bill tries to post to somebody else's blog, and fails
    Given I am logged in as Dr. Bill

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.