Documentation ¶
Overview ¶
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func Check(config *ConfigHeader, result *Result) error
- func CheckFile(file string, config *ConfigHeader, result *Result) error
- func Fix(file string, config *ConfigHeader, result *Result) error
- func GenerateLicenseHeader(style *comments.CommentStyle, config *ConfigHeader) (string, error)
- func InsertComment(file string, style *comments.CommentStyle, config *ConfigHeader, ...) error
- type CommentOption
- type ConfigHeader
- type LicenseConfig
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(config *ConfigHeader, result *Result) error
Check checks the license headers of the specified paths/globs.
func CheckFile ¶
func CheckFile(file string, config *ConfigHeader, result *Result) error
CheckFile checks whether or not the file contains the configured license header.
func Fix ¶
func Fix(file string, config *ConfigHeader, result *Result) error
Fix adds the configured license header to the given file.
func GenerateLicenseHeader ¶
func GenerateLicenseHeader(style *comments.CommentStyle, config *ConfigHeader) (string, error)
func InsertComment ¶
func InsertComment(file string, style *comments.CommentStyle, config *ConfigHeader, result *Result) error
Types ¶
type CommentOption ¶
type CommentOption string
var ( Always CommentOption = "always" Never CommentOption = "never" OnFailure CommentOption = "on-failure" ASFNames = regexp.MustCompile("(?i)(the )?(Apache Software Foundation|ASF)") )
type ConfigHeader ¶
type ConfigHeader struct { License LicenseConfig `yaml:"license"` Pattern string `yaml:"pattern"` Paths []string `yaml:"paths"` PathsIgnore []string `yaml:"paths-ignore"` Comment CommentOption `yaml:"comment"` // LicenseLocationThreshold specifies the index threshold where the license header can be located, // after all, a "header" cannot be TOO far from the file start. LicenseLocationThreshold int `yaml:"license-location-threshold"` }
func (*ConfigHeader) Finalize ¶
func (config *ConfigHeader) Finalize() error
func (*ConfigHeader) GetLicenseContent ¶
func (config *ConfigHeader) GetLicenseContent() string
func (*ConfigHeader) NormalizedLicense ¶
func (config *ConfigHeader) NormalizedLicense() string
NormalizedLicense returns the normalized string of the license content, "normalized" means the linebreaks and Punctuations are all trimmed.
func (*ConfigHeader) NormalizedPattern ¶
func (config *ConfigHeader) NormalizedPattern() *regexp.Regexp
func (*ConfigHeader) ShouldIgnore ¶
func (config *ConfigHeader) ShouldIgnore(path string) (bool, error)