Skip to content

Commit

Permalink
Merge pull request #1410 from cubiest/init_tags
Browse files Browse the repository at this point in the history
Tiny refactoring: remove unnecessary parameters.
  • Loading branch information
stephenafamo authored Oct 23, 2024
2 parents 9eaa10e + 0699909 commit bc92201
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions boilingcore/boilingcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func New(config *Config) (*State, error) {
}
}()

if len(config.Version) > 0 {
if len(s.Config.Version) > 0 {
noEditDisclaimer = []byte(
fmt.Sprintf(noEditDisclaimerFmt, " "+config.Version+" "),
fmt.Sprintf(noEditDisclaimerFmt, " "+s.Config.Version+" "),
)
}

Expand All @@ -89,10 +89,10 @@ func New(config *Config) (*State, error) {
}
}

s.Driver = drivers.GetDriver(config.DriverName)
s.Driver = drivers.GetDriver(s.Config.DriverName)
s.initInflections()

err := s.initDBInfo(config.DriverConfig)
err := s.initDBInfo()
if err != nil {
return nil, errors.Wrap(err, "unable to initialize tables")
}
Expand Down Expand Up @@ -124,12 +124,12 @@ func New(config *Config) (*State, error) {
return nil, errors.Wrap(err, "unable to initialize the output folders")
}

err = s.initTags(config.Tags)
err = s.initTags()
if err != nil {
return nil, errors.Wrap(err, "unable to initialize struct tags")
}

err = s.initAliases(&config.Aliases)
err = s.initAliases()
if err != nil {
return nil, errors.Wrap(err, "unable to initialize aliases")
}
Expand Down Expand Up @@ -417,8 +417,8 @@ func findTemplates(root, base string) (map[string]templateLoader, error) {
}

// initDBInfo retrieves information about the database
func (s *State) initDBInfo(config map[string]interface{}) error {
dbInfo, err := s.Driver.Assemble(config)
func (s *State) initDBInfo() error {
dbInfo, err := s.Driver.Assemble(s.Config.DriverConfig)
if err != nil {
return errors.Wrap(err, "unable to fetch table data")
}
Expand Down Expand Up @@ -671,7 +671,7 @@ func (s *State) initInflections() {

// initTags removes duplicate tags and validates the format
// of all user tags are simple strings without quotes: [a-zA-Z_\.]+
func (s *State) initTags(tags []string) error {
func (s *State) initTags() error {
s.Config.Tags = strmangle.RemoveDuplicates(s.Config.Tags)
for _, v := range s.Config.Tags {
if !rgxValidTag.MatchString(v) {
Expand All @@ -682,8 +682,8 @@ func (s *State) initTags(tags []string) error {
return nil
}

func (s *State) initAliases(a *Aliases) error {
FillAliases(a, s.Tables)
func (s *State) initAliases() error {
FillAliases(&s.Config.Aliases, s.Tables)
return nil
}

Expand Down

0 comments on commit bc92201

Please sign in to comment.