stylist.fortran#
Rules relating to Fortran source.
Classes
Checks that all automatically assigned character arrays used as subroutine or function arguments have intent(in) to avoid writing outside the given array. |
|
|
Checks that no attempt is made to use the specific module unless it is in one of the excepted modules. |
Traps any characters which do not fall in the list of those allowed in Fortran source. |
|
Parent for style rules pertaining to Fortran source. |
|
Catches cases where an intrinsic module is used with the "intrinsic" keyword ommitted. |
|
|
Ensures kind names match a specified pattern. |
Catches cases where a "do" construct is exited but not explicitly named. |
|
|
Catches cases where code blocks which could have an |
Catches cases where a function or subroutine's dummy arguments don't have specified intent. |
|
|
Catches cases where a "use" statement is present but has no "only" clause. |
Catches cases where a pointer is declared without being initialised. |
|
|
Checks that all literal values have their kind specified. |
- class stylist.fortran.AutoCharArrayIntent#
Bases:
FortranRule
Checks that all automatically assigned character arrays used as subroutine or function arguments have intent(in) to avoid writing outside the given array.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.ForbidUsage(name, exceptions=())#
Bases:
FortranRule
Checks that no attempt is made to use the specific module unless it is in one of the excepted modules.
- Parameters:
name (
str
) – Name of module to forbid.exceptions (
Sequence
[Union
[str
,Pattern
]]) – names (or name patterns) in which module may be used.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.FortranCharacterset#
Bases:
Rule
Traps any characters which do not fall in the list of those allowed in Fortran source. This takes into account the fact that there is no restriction on what may appear in comments or strings.
- examine(subject)#
Examines the provided source code object for issues.
- Parameters:
subject (
FortranSource
) – The source file to be examined.- Return type:
List
[Issue
]- Returns:
All issues found with the source.
- class stylist.fortran.FortranRule#
Bases:
Rule
,ABC
Parent for style rules pertaining to Fortran source.
- examine(subject)#
Base for rules which scruitinise the parse tree of Fortran source.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- abstract examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.IntrinsicModule#
Bases:
FortranRule
Catches cases where an intrinsic module is used with the “intrinsic” keyword ommitted.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.KindPattern(*, integer=None, real=None)#
Bases:
FortranRule
Ensures kind names match a specified pattern.
Patterns are set only for integer and real data types however Fortran supports many more. Logical and Complex for example. For those cases a default pattern of “.*” is used to accept anything.
- Parameters:
integer (
Union
[str
,Pattern
,None
]) – Regular expression which integer kinds must match.real (
Union
[str
,Pattern
,None
]) – Regular expression which real kinds must match.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.LabelledDoExit#
Bases:
FortranRule
Catches cases where a “do” construct is exited but not explicitly named.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.MissingImplicit(require_everywhere=False)#
Bases:
FortranRule
Catches cases where code blocks which could have an
implicit
statement don’t.- Parameters:
require_everywhere (
Optional
[bool
]) – By default the rule checks only in places which require animplicit
statement. Set this argument to check everywhere animplicit
could exist.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.MissingIntent#
Bases:
FortranRule
Catches cases where a function or subroutine’s dummy arguments don’t have specified intent.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.MissingOnly(ignore=None)#
Bases:
FortranRule
Catches cases where a “use” statement is present but has no “only” clause.
- Parameters:
ignore (
Optional
[List
[str
]]) – List of module names which are not required to have an “only” clause.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.MissingPointerInit#
Bases:
FortranRule
Catches cases where a pointer is declared without being initialised.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.
- class stylist.fortran.NakedLiteral(integers=True, reals=True)#
Bases:
FortranRule
Checks that all literal values have their kind specified.
Checking of integers and reals are controlled separately so you can have one and not the other.
- examine_fortran(subject)#
Examines the provided Fortran source code object for an issue.
- Parameters:
subject (
FortranSource
) – Source file to examine.- Return type:
List
[Issue
]- Returns:
Issues found with the source.