Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct initialisms as suggested by golint #969

Closed
wants to merge 1 commit into from

Conversation

anthonyfok
Copy link
Member

First step to use initialisms that golint suggests, for example:

Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag) as well as struct fields like .BaseUrl and .Url that are used in Go HTML templates need more work to maintain backward-compatibility, and thus are NOT yet dealt with in this commit.

First step in fixing #959.

First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing gohugoio#959.
@anthonyfok
Copy link
Member Author

For the sake of full disclosure 😉, this is the script that I used with gofmt to do the bulk of the conversion. Note the exit near the end, i.e. the final for loop for BaseUrl and Url is not executed.

#!/bin/bash

for rule in \
    'baseUrl -> baseURL' \
    'oldBaseUrl -> oldBaseURL' \
    'fixUrl -> fixURL' \
    'pUrl -> pURL' \
    'refUrl -> refURL' \
    'remoteUrlLock -> remoteURLLock' \
    'UrlLock -> URLLock' \
    'UrlUnlock -> URLUnlock' \
    'absUrlInit -> absURLInit' \
    'absurlMatcher -> absURLMatcher' \
    'absurlReplacer -> absURLReplacer' \
    'BenchmarkAbsUrl -> BenchmarkAbsURL' \
    'BenchmarkXmlAbsUrl -> BenchmarkXMLAbsURL' \
    'dqHtmlMatch -> dqHTMLMatch' \
    'sqHtmlMatch -> sqHTMLMatch' \
    'dqXmlMatch -> dqXMLMatch' \
    'sqXmlMatch -> sqXMLMatch' \
    'dqHtml -> dqHTML' \
    'sqHtml -> sqHTML' \
    'dqXml -> dqXML' \
    'sqXml -> sqXML' \
    'TestAbsUrl -> TestAbsURL' \
    'TestFixUrl -> TestFixURL' \
    'TestXMLAbsUrl -> TestXMLAbsURL' \
    'CliBaseUrl -> CLIBaseURL' \
    'CfgBaseUrl -> CfgBaseURL' \
    'DocumentId -> DocumentID' \
    'PlainIdAnchors -> PlainIDAnchors' \
    'UniqueId -> UniqueID' \
    'uniqueId -> uniqueID' \
    'replaceInHtml -> replaceInHTML' \
    'replaceInXml -> replaceInXML' \
    'SafeCss -> SafeCSS' \
    'SafeHtml -> SafeHTML' \
    'SafeHtmlAttr -> SafeHTMLAttr' \
    'SafeUrl -> SafeURL' \
    'paginationUrlFactory -> paginationURLFactory' \
    'newPaginationUrlFactory -> newPaginationURLFactory' \
    'CanonifyUrls -> CanonifyURLs' \
    'canonifyUrls -> canonifyURLs' \
    'PrettifyUrl -> PrettifyURL' \
    'PrettifyUrlPath -> PrettifyURLPath' \
    'SanitizeUrl -> SanitizeURL' \
    'SanitizeUrlKeepTrailingSlash -> SanitizeURLKeepTrailingSlash' \
    'sanitizeUrlWithFlags -> sanitizeURLWithFlags' \
    'Urlize -> URLize' \
    'UrlizeAndPrep -> URLizeAndPrep' \
    'UrlPrep -> URLPrep' \
    'UglyUrls -> UglyURLs' \
    'uglyUrls -> uglyURLs' \
    'TestSafeCss -> TestSafeCSS' \
    'TestSafeHtml -> TestSafeHTML' \
    'TestSafeHtmlAttr -> TestSafeHTMLAttr' \
    'TestSafeUrl -> TestSafeURL' \
    'GoHtmlTemplate -> GoHTMLTemplate' \
    'GetHtmlRenderer -> GetHTMLRenderer' \
    'tstHtmlContent -> tstHTMLContent' \
    'menuEntryUrl -> menuEntryURL' \
    'menuEntryXml -> menuEntryXML' \
    'menuId -> menuID' \
    'findTestMenuEntryById -> findTestMenuEntryByID' \
    'removeTomlIdentifier -> removeTOMLIdentifier' \
    'HandleJsonMetaData -> HandleJSONMetaData' \
    'HandleTomlMetaData -> HandleTOMLMetaData' \
    'HandleYamlMetaData -> HandleYAMLMetaData' \
    'TestDataDirJson -> TestDataDirJSON' \
    'TestDataDirYamlWithOverridenValue -> TestDataDirYAMLWithOverridenValue' \
    'tstCreateMenuPageWithNameToml -> tstCreateMenuPageWithNameTOML' \
    'tstCreateMenuPageWithIdentifierToml -> tstCreateMenuPageWithIdentifierTOML' \
    'tstCreateMenuPageWithNameYaml -> tstCreateMenuPageWithNameYAML' \
    'tstCreateMenuPageWithIdentifierYaml -> tstCreateMenuPageWithIdentifierYAML' \
    'GetJson -> GetJSON' \
    'GetCsv -> GetCSV' \
    'parseCsv -> parseCSV' \
    'TestParseCsv -> TestParseCSV' \
    'TestMenuWithHashInUrl -> TestMenuWithHashInURL' \
    'TestMenuWithUnicodeUrls -> TestMenuWithUnicodeURLs' \
    'doTestMenuWithUnicodeUrls -> doTestMenuWithUnicodeURLs' \
; do
    echo "$rule"
    gofmt -r "$rule" -w */*.go *.go
done

# Can't change blackfriday.HtmlRendererParameters yet, I think...

gofmt -r 'BaseUrl -> BaseURL' -w commands/*.go

exit

# Problematic ones: BaseUrl and Url (e.g. .Site.BaseUrl and .Page.Url)

for rule in \
    'BaseUrl -> BaseURL' \
    'Url -> URL' \
; do
    gofmt -r "$rule" -w */*.go *.go
done

@bep
Copy link
Member

bep commented Mar 11, 2015

Merged in 67df33f Good job, cool script.

@bep bep closed this Mar 11, 2015
tryp added a commit to tryp/material-design that referenced this pull request Jun 11, 2015
Hugo adopted golint initialism formatting with:
gohugoio/hugo#969

Hugo 0.14 throws an error saying compatibility with
the old capitalizations will be removed in 0.15

This change was produced with a quick and dirty
`grep -Irl BaseUrl | xargs ser -i -e "s/BaseUrl/BaseURL"`
@github-actions
Copy link

github-actions bot commented Mar 4, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants